Other Parts Discussed in Thread: C2000WARE
Hello
I try to use SPI communication to read and write the data to sensor chip. It is 4 wire SPI communication and 28035 is used as Master mode. For the sensor chip, the data transfer starts with falling edge of CSn(pin 19) and SPI commands are executed at the rising edge of CSn. However, it seems that I can read and write data correctly. I wrote something as follows. Could anyone help me to find the problem? It is my first time to use SPI and any help is appreciated.
#define SPI_WRITE_MICRO(v) \
SpiaRegs.SPITXBUF = v; \
GpioDataRegs.GPACLEAR.bit.GPIO19 = 1; \
while(SpiaRegs.SPIFFRX.bit.RXFFST !=1) { }\
GpioDataRegs.GPASET.bit.GPIO19 = 1; \
spi_read_dummy = SpiaRegs.SPIRXBUF;
#define SPI_READ_MICRO(v) \
SpiaRegs.SPITXBUF = spi_write_dummy;\
GpioDataRegs.GPACLEAR.bit.GPIO19 = 1; \
while(SpiaRegs.SPIFFRX.bit.RXFFST !=1) { } /*Check against sent data*/ \
GpioDataRegs.GPASET.bit.GPIO19 = 1; \
v = SpiaRegs.SPIRXBUF;