Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.

Dependents:   FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more

Fork of SPI_TFT by Peter Drescher

Issue: Assertion failed when using capacitive touch

After initialization of:

RA8875 lcd(PA_7, PA_6, PA_5, PB_6, NC, PB_9, PB_8, PC_7, "tft");

The interrupt comes too early and I get on the serial port:

``` ++ MbedOS Error Info ++ Error Status: 0x80FF0144 Code: 324 Module: 255 Error Message: Assertion failed: id Location: 0x8004A49 File: ./mbed-os/events/Event.h+166 Error Value: 0x0 Current Thread: application_unnamed_thread Id: 0x20001A68 Entry: 0x8007991 StackSize: 0x1000 StackMem: 0x20003B68 SP: 0x20007EAC For more info, visit: https://mbed.com/s/error?error=0x80FF0144&tgt=NUCLEO_F091RC MbedOS Error Info ```

4 comments:

21 May 2020

The problem here is that the init procedure for the touch panel controller and the interrupt service routine for the touch detection are using the same I2C resource object. And for some reason there is a touch event during initialization even without touching, which creates a I2C resource collision. You can emulate it by connecting the interrupt pin after initialization. The solution here is to fix the driver with a semaphore everywhere a thread tries to access the I2C object:

if (IICaccess.try_acquire()) { m_i2c->write(m_addr, (const char *)&reg, 1); IICaccess.release(); }

22 May 2020

I investigated this problem and I encountered an important bug in the driver. Using a semaphore is not the best solution because a range of I2C transactions can be interrupted by other I2C transactions from another thread and a complete bunch cannot be finished in a clean way. It's better to make it safe by design. This problem occurs during startup. The IRQ of the capacitive touch panel is enabled in the constructor before the initialization of the touch panel with the FT5206_Init() function. When the initialization happens there are some I2C transactions running and when the interrupt fires at the same time (which sometimes happens), the initialization procedure is interrupted and Mbed-OS chraches. The solution is to disable the interrupt in the first place in the constructor, disable it at the beginning of the FT5206_Init() and enable it when the initialization has been finished. In that way you may call TouchPanelInit() whenever you want in a safe way, and you force the programmer to call initialization function before interrupts can take place.

22 May 2020

I tried to commit the fixes on a local branch but I do not find or have the possibility to do a pull request. I cannot find it on github either. I think your library is protected?

22 May 2020

as is:

The interrupt for the capacitive touch panel is enabled before executing the initialization function of the FT5206 chip. If you have a breadboard with long wires, there are voltage dips on the IRQ line during initialization because of the I2C transactions (interference). Those spikes can invoke an early interrupt without touching the panel. The position registers are readout and this clashes with the initialization which is going on. The result is a crash of the ARM processor, probably because of wrong I2C transactions.   

changes: <<code>> Disable the interrupt in the constructor, disable it again in the beginning of the initialization procedure and enable it when the initialization procedure has been finished. In that way it is always safe to call the initialization function and I2C interactions will not collide. You can also put the initialization procedure before the IRQ activation, but then the user may not call it separately. Be also aware of crashes when spikes are on power supply. (eg pc goes in sleep while board is USB powered) <</code>>