SPI MOSI not moving as expected

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI MOSI not moving as expected

Jump to solution
412 Views
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. 

Labels (1)
Tags (1)
0 Kudos
1 Solution
402 Views
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.

View solution in original post

0 Kudos
4 Replies
403 Views
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 Kudos
371 Views
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 Kudos
397 Views
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 Kudos
391 Views
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 Kudos