Other Parts Discussed in Thread: C2000WARE
Hi Champ,
I am asking for my customer.
The F280025C which is a master, writes a series of data to an EEPROM(slave), and echo-back and read the data which was sent from MCU.
They are using FIFO without interrupt, and the transmission character length is 8 bit which is set in SPICHAR.
Below screenshot is the register status when MCU is writing a series data (10, 9, 8, ..., 1) to EEPROM, and it is sure that EEPROM is echo-backing data (10, 9, 8, ..., 1) back on the probe.
As it could seen that 0A arrives in the SPIDAT shift register in LSB, it is supposed that the data should then be forwarded to the SPIRXBUF buffer, while SPIRXBUF is always 0x00FF.
So that when the SPIRXBUF is copied into a temporary variable stored in an array, the values in the array always remain 255.
EEPROM_read_page(ADDRESS_PAGE0, &data_to_read[0], 10); // Read data function is called in main();
void EEPROM_read_page(uint16_t ADDRESS,uint16_t *Data, uint16_t N) // The function of read data from SPIRXBUF
{
uint16_t dummy_write = 0xFF00;
// push out command
SpiaRegs.SPITXBUF = 0x0300 // READ OP CODE;
SpiaRegs.SPITXBUF = (ADDRESS) & 0xff00;
SpiaRegs.SPITXBUF = (ADDRESS<<8) & 0xff00;
while (SpiaRegs.SPIFFRX.bit.RXFFST != 0)
{
dummy_read = SpiaRegs.SPIRXBUF;
}
for( uint16_t i=0 ; i<N ; i++)
{
SpiaRegs.SPITXBUF = dummy_write;
*(Data+i) = 0x00FF & SpiaRegs.SPIRXBUF;
}
return;
}
Would the expert kindly tell me where the problem is in the code ?
And please briefly explain how is actually the SPIDAT copy data to SPIRXBUF in FIFO ?
Thanks and regards