This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi
uint16_t read_data[3] ={0};
uint16_t rData=0;
uint16_t TXRXError=0;
uint32_t sData32=0,rData32 =0;
SPI configuaration as follows
SPI_disableModule(mySPI0_BASE);
SPI_setConfig(mySPI0_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0 ,SPI_MODE_MASTER, 1000000, 8);
SPI_enableFIFO(mySPI0_BASE);
SPI_setTxFifoTransmitDelay(mySPI0_BASE,0);
SPI_disableHighSpeedMode(mySPI0_BASE);
// SPI_enableLoopback(mySPI0_BASE);
SPI_disableLoopback(mySPI0_BASE);
SPI_enableTalk(mySPI0_BASE);
SPI_disableInterrupt(mySPI0_BASE, SPI_INT_TXFF);
SPI_setEmulationMode(mySPI0_BASE, SPI_EMULATION_FREE_RUN);////!Set so breakpoints don't disturb xmission
SPI_enableModule(mySPI0_BASE);
Master can validate data received by slave is correct by validating second response from the slave.
I am transmitting same 24-bit data twice to the slave to get response of 24 bits from slave. I am comparing first 24bits transmitted with 2nd time received 24bits of the data.but I am not getting correct data.
I am missing something while receiving data.
SPI_transmit24Bits(mySPI0_BASE, sData32, 0);
SPI_transmit24Bits(mySPI0_BASE, sData32, 0);
read_data[0] = SPI_readRxEmulationBuffer(mySPI0_BASE);
read_data[1] = SPI_readRxEmulationBuffer(mySPI0_BASE);
read_data[2] = SPI_readRxEmulationBuffer(mySPI0_BASE);
rData = read_data[1] << 8 ;
rData = rData | read_data[2];
Thanks in advance
Hi Aruna,
Our subject matter expert is currently out of office and will get back to you the following business day.
Best regards,
Ryan Ma
If you're trying to receive 24 bits from target (slave), why are you using SPI_transmit24Bits function?
Are you trying to transmit contents of sData32 variable?
Did you already look into readData function in spi_ex6_eeprom example?
Regards,
Manoj
If you're trying to receive 24 bits from target (slave), why are you using SPI_transmit24Bits function?
Ans: I would like to transmit 24bits data to slave and same time I would like to receive 24bit response from the slave. so I am using SPI_transmit24Bits function to transmit the data.
Are you trying to transmit contents of sData32 variable?
Ans:Yes.Here also I have one question, will Left justified 24bit data will get transmitted or right justified 24bits get transmit?
Did you already look into readData function in spi_ex6_eeprom example?
No.
I have one more question when to use FIFO enabled SPI or when not to use?
Thanks in advance
Aruna,
For transmit and receiving at the same time you can use the below function
For sending / receiving 24 bits, you need to set charLength = 8, numofWords = 3 (8 bits x 3 = 24 bits)
I have one more question when to use FIFO enabled SPI or when not to use?
Typically, FIFO are added to reduce the frequency at which SPI generates CPU interrupt. If you are using polling option, then you don't need to worry about it.
Regards,
Manoj