CC3000 timing

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
Frida
Posts: 45
Joined: Sat Jan 30, 2016 2:20 pm
Location: Middelfart, Denmark

CC3000 timing

Post by Frida » Wed Feb 17, 2016 6:52 pm

From micropython/drivers/cc3000/src/ccspi.c I found this slice, as I have the following questions for:
__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);
Yes Frida is my watchdog!

Post Reply