__delay_cycles(1200) gives 50 usec at 24MHZ. Should x*=6 not be x*=7, as 24*7= 168?
Next, are this driver used with the other cpu's with lower MHZ?
If so, then the timing is not correct.
Code: Select all
STATIC void __delay_cycles(volatile int x)
{
x *= 6; // for 168 MHz CPU
while (x--);
}
STATIC long SpiFirstWrite(unsigned char *ucBuf, unsigned short usLength)
{
DEBUG_printf("SpiFirstWrite %lu\n", sSpiInformation.ulSpiState);
CS_LOW();
// Assuming we are running on 24 MHz ~50 micro delay is 1200 cycles;
__delay_cycles(1200);
// SPI writes first 4 bytes of data
SpiWriteDataSynchronous(ucBuf, 4);
__delay_cycles(1200);