
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 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.
已解决! 转到解答。
This looks more like the MOSI or MISO ports are not configured correctly, or check if the hardware of these two ports is affected.

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!!!
