SPI receive data problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User16529
Level 4
Level 4
First solution authored
Hi!
I'm using SPI on USIC0_CH1 of a xmc4800 144x196 chip and when i use the function XMC_SPI_CH_GetReceivedData(XMC_SPI0_CH1) i always get 0.
On the oscilloscope i see that both MISO and MOSI are carrying data, so why the read function gives 0?


Here there is my code



uint16_t frame_out = 0x5555;
uint16_t read = 0;

/*Enable Slave Select line 0*/
XMC_SPI_CH_EnableSlaveSelect(XMC_SPI0_CH1, XMC_SPI_CH_SLAVE_SELECT_0);

XMC_SPI_CH_Transmit(XMC_SPI0_CH1, frame_out, XMC_SPI_CH_MODE_STANDARD);

/*Wait till the byte has been transmitted*/
while((XMC_SPI_CH_GetStatusFlag(XMC_SPI0_CH1) & XMC_SPI_CH_STATUS_FLAG_TRANSMIT_SHIFT_INDICATION) == 0U);
XMC_SPI_CH_ClearStatusFlag(XMC_SPI0_CH1, XMC_SPI_CH_STATUS_FLAG_TRANSMIT_SHIFT_INDICATION);


while((XMC_SPI_CH_GetStatusFlag(XMC_SPI0_CH1) & XMC_SPI_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION) == 0U);
XMC_SPI_CH_ClearStatusFlag(XMC_SPI0_CH1, XMC_SPI_CH_STATUS_FLAG_RECEIVE_INDICATION);

read = XMC_SPI_CH_GetReceivedData(XMC_SPI0_CH1);

/*Disable Slave Select line */
XMC_SPI_CH_DisableSlaveSelect(XMC_SPI0_CH1);



These are the pins i'm using for SPI:

P2.2 MISO
P3.5 MOSI
P2.4 SCLK
P2.3 CS
0 Likes
1 Reply
User16898
Level 4
Level 4
I think that
First you need to invoke
XMC_SPI_CH_GetReceivedData
then
while(flags...).
0 Likes