I know this is a very specific question about an electronic chip, but I am sure some of you are expert on that too.
I try to drive a TLC5940 with a Raspberry Pi 3b in ARM assembly.
I use 3 cores. Core 0, after managing the initializations (GPIO, screen framebuffer, etc...), is modifying the buffer where the led colors are stored, core 1 is managing BLANK, XLAT and GSCLK while core 2 is transfering data from LED color buffer to the input shift registers (SIN and SCLK). There is 1 var called "BufferFilled" in memory that allow synchronization between core1 and core 2. Initially, this var is 0 (LED color buffer not empty).
I've read comprehensively the datasheet and my loops are:
For Core 1:
- Set BLANK to H(igh)
- While BufferFilled=0 go to MainLoop1
- Set BLANK to H
- Set XLAT to H
- Set XLAT to L(ow)
- Set BufferFilled=1 (core 2 may start again to filled the input shift registers)
- Set BLANK to L
- Using the internal timer to set GSLK to H then to L at a regular interval (every 4 µs for me then I have around 60 cycles per second )
- While we don't have 4096 pulses, go back to GSLKLoop
- Return to MainLoop1
- While BufferFilled=1 go to MainLoop2
- Read a byte in the buffer (from the last to the first to respect MSB to LSB)
- Check the most significant bit and set SIN accordingly
- Set SCLK to H then to L
- Shift the data byte to the left
- If we don't have check the full byte, go back to BitLoop2
- To shift from 8 bit value to 12 bit value, add 4 more SIN=L then SCLK=H then SCLK=L
- Check if we have done with all the bytes, if not go back to ByteLoop2
- Set BufferFilled=1
- Go back to MainLoop2
It works well, but not for long, I have a video that shows it there:
And that is about the longest time it ever worked... As you see, at the end, it stops.
I have check with values written on the screen and there is no memory leak (stack pointers are constant, displaying the memory where the vars are shows that it behaves normally), so what?
Do you have any idea why this does not work indefinitely?
Thanks for your help.
PS: I may produce my code if necessary.