Hi, dear all.
I need to communicate with a FLASH, so I set MCBSP as SPI master, 8bit, MSB.
I am sure SPI write and read alone (before reading need to write a dummy number) will be ok.
However, practical applications, often need to wirte and then read followed, for example, reading a
register from the slave :we need to write address, write the control word, and then read. There have a problem! ! !
For example:
SPI_Send_Bytet (Reg_H); // write registers high 8BIT address
SPI_Send_Byte (Reg_L); // write low 8BIT address
SPI_Send_Byte (FDM2 | RWB_READ | (s * 0x20 + 0x08)); // write control byte via SPI
SPI_Send_Byte (0); // write dummy
X_H = SPI_Read_Byte (); // read 16BIT register high 8BIT
SPI_Send_Byte (0); // write dummy
X_L = SPI_Read_Byte (); // read the low 8BIT of 16BIT register /////////////////////////////////// ////////////////////////////////////////////////// //////////////////////////////
There are five groups 8bit clock sequence in the course of operation.
The first three groups 8bit correspond to the host write 3 bytes, then the last two 8bit for the host reading 2 bytes
I used an oscilloscope to observe, mcbsp data transmission pin, the data are OK.
But mcbsp data receive pins, within this 5 group 8bit clock sequence,
I know that , the 4th,and 5th clock group corresponding data is I need.
However, I read the data use above, I can not get data I need ,every time , it maybe the 1st 2nd data, or so .
it will be appreciate if somebody can tell me ,how to get the right data?