SPI MOSI not moving as expected

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

SPI MOSI not moving as expected

跳至解决方案
425 次查看
m_mishrikey
Contributor III

My S32K148 SPI2 peripheral was previously working but something seems to be misconfigured now.

I am communicating with an ADS8028 ADC chip.

When I try to send a write command, the MOSI line goes high and stays high, instead of sending data.

 

 

int16_t get_MCC_ADC_tempC_x10(){
	uint16_t adc_tx_buf[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	uint16_t adc_rx_buf[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	uint32_t baudCalc;
	lpspi_state_t masterState;
 
	LPSPI_DRV_MasterInit(SPI2, &masterState, &SPI2_MasterConfigADCs);
	LPSPI_DRV_MasterConfigureBus(SPI2, &SPI2_MasterConfigADCs, &baudCalc);
 
	LPSPI_DRV_SetPcs(SPI2,LPSPI_PCS1,LPSPI_ACTIVE_LOW);
 
	adc3_temp_conv_complete = false;
	adc_tx_buf[0] = (adcconf | TSENSE_ON );	 // ADC3 temp sense, no averaging
	adc_tx_buf[1] = (adcconf | AIN0);
 
	LPSPI_DRV_MasterTransferBlocking(SPI2, (uint8_t *)&adc_tx_buf, (uint8_t *)&adc_rx_buf, 2*BUFFER_SIZE*2U, ADC_TIMEOUT);
 
 //	while(!adc3_temp_conv_complete){}  	//Flag set by ISR externally									 
 // Port A interrupt will set this true when conversion is completed.

        // Now read back temp data word:
	adc_tx_buf[0] = 0;
	LPSPI_DRV_MasterTransferBlocking(SPI2, (uint8_t *)&adc_tx_buf, (uint8_t *)&adc_rx_buf, 2*BUFFER_SIZE*1U, ADC_TIMEOUT);
	adc3_temp_conv_complete = false;

...
}
 

 

 

MOSI stuck highMOSI stuck high

You might think that the buffer is mistakenly filled with 0xFFFF, however I can confirm the value of (adcconf | T_SENSE) is 0x8020, and the value of (adcconf | AIN0) is 0xA000. 

标签 (1)
标记 (1)
0 项奖励
1 解答
415 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@m_mishrikey zh 

This looks more like the MOSI or MISO ports are not configured correctly, or check if the hardware of these two ports is affected.

在原帖中查看解决方案

0 项奖励
4 回复数
416 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@m_mishrikey zh 

This looks more like the MOSI or MISO ports are not configured correctly, or check if the hardware of these two ports is affected.

0 项奖励
384 次查看
m_mishrikey
Contributor III

I was making a measurement error, and also confusing input and output.

I wish the manual used MOSI/MISO instead of SOUT/SIN, somehow that always trips me up.

Anyway, thanks for the support!!!

0 项奖励
410 次查看
m_mishrikey
Contributor III

In terms of configuration, not sure what to check.  SPI2 is set to the correct pins, and I also believe the PEX settings are fine.

MicrosoftTeams-image (2).png

MicrosoftTeams-image (3).png

 

0 项奖励
404 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@m_mishrikey

I can't see any problem with the configuration. You can only test the SPI port on the MCU side, disconnect the MCU and Slave side, and test the output waveform.

0 项奖励