This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

spim3 data corrupted sometimes after spi reset

Hi,

I am using spim3 16Mhz and sometimes the spi tx data had the first byte as same as previous last byte and sensor can not react and timed out because of the wrong data.

Actually, I already have a dedicated memory for spim3 to avoid the anomaly [198] but I figured out the problem disappeared after removing spi reset code like below in initializing FW.

Of course there is also spi init fuction before using spim3 after the spi reset code.

I think that spi channel reset should not affect the problem but it affects. Can anyone explain this symptom?

One more weird thing, this spi reset code has stayed for a while but the problem is happening much more frequently after changing other unrelated code like removing or changing logs in other drivers.

    // reset SPI channels to allow spi init in F/W
    // SPI2 reset
    *(volatile uint32_t*)0x40023FFC = 0;
    __DSB();
    *(volatile uint32_t*)0x40023FFC = 1;
    __DSB();

    // SPIM3 reset
    *(volatile uint32_t*)0x4002FFFC = 0;
    __DSB();
    *(volatile uint32_t*)0x4002FFFC = 1;
    __DSB();

Thank you.

Parents
  • Hi

    I'm not sure I understood your initial statement correctly. What exactly is it that happens on the SPI lines, and why exactly are you power cycling the SPI peripherals like this during init? When resetting the peripherals by power cycling them, you should make sure that you uninitialize the driver and execute the following snippet, as I'm not sure your procedure is correct:

    *(volatile uint32_t *)0x4002FFFC = 0;   // Power down SPIM3
    *(volatile uint32_t *)0x4002FFFC;       //
    *(volatile uint32_t *)0x4002FFFC = 1;   // Power on SPIM3 so it is ready for next time

    Best regards,

    Simon

Reply
  • Hi

    I'm not sure I understood your initial statement correctly. What exactly is it that happens on the SPI lines, and why exactly are you power cycling the SPI peripherals like this during init? When resetting the peripherals by power cycling them, you should make sure that you uninitialize the driver and execute the following snippet, as I'm not sure your procedure is correct:

    *(volatile uint32_t *)0x4002FFFC = 0;   // Power down SPIM3
    *(volatile uint32_t *)0x4002FFFC;       //
    *(volatile uint32_t *)0x4002FFFC = 1;   // Power on SPIM3 so it is ready for next time

    Best regards,

    Simon

Children
Related