Teensy LC port of OctoWS2811

Status
Not open for further replies.

markb

Active member
Here's my attempt at porting OctoWS2811 to Teensy LC. It does seem work, based on my minimal testing. I've tested with a 6-pixel strip of WS2812B chips and a 22-pixel strand of WS2811 chips. In both cases, I drove the pixels directly from the Teensy's GPIO pins (no buffer chip available to change the logic level). I lowered the Vin voltage to the pixels to compensate. I also examined the GPIO output with a logic analyzer. The timing isn't perfectly consistent but it seems to be good enough for my tests. Perhaps it's not good enough in every situation, though.

The most significant things I changed from Paul's code.

1) Added a new formula for the timer mod: F_CPU / frequency - 1 (consistent with the datasheet).
2) Changed the trigger order, so CH0 triggers DMA1, CH1 triggers DMA2 and OV triggers DMA3. (Original order had OV triggering DMA1, but I found OV is the last event.)
3) I found that DMA3 doesn't always set the output low at the end of the stream. It does always seem to generate the interrupt. I haven't figured out why this happens, but I added a workaround by setting the output low in the ISR.

So really I just tweaked the code that Paul had already added.

Not sure if this is good enough to upstream into the official library, but maybe someone will find it useful.

Cheers!
 

Attachments

  • OctoWS2811.cpp
    14.6 KB · Views: 168
I'd certainly be interested in any feedback anyone has! Here's my GitHub repo, which might make for easier viewing of the code:

https://github.com/baysinger/OctoWS2811

Paul previously posted this:

If you look in the code, you'll see I put some work into attempting LC support. It almost works, but LC just isn't fast enough without the more sophisticated bus structure of the 3.x chips.

I'm curious what kind of test I can do to expose this issue? Since I didn't really do anything special with my port, I expect this issue to still be there, but I don't really understand the issue, or how to trigger it.

Thanks!
 
Thanks. I'll give it a try here soon. The 1920 LED test board is sitting right next to my desk. ;)

Early (well over a year ago) when I worked on this, I spent most of the time viewing waveforms on a scope. Something strange would happen after many bytes. I never did resolve it.
 
I get the following when I compile BasicTest for teensylc.
Teensy 3.2 compiles without error.
What does this mean.
Thanks.

Code:
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 120 bytes

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "OctoWS2811.h"
 Used: C:\Users\FPV\Qsync\Arduino\libraries\OctoWS2811
 Not used: C:\Users\FPV\Qsync\Arduino\libraries\arduino_307591
 Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\OctoWS2811
Using library OctoWS2811 at version 1.3 in folder: C:\Users\FPV\Qsync\Arduino\libraries\OctoWS2811 
Error compiling for board Teensy LC.
 
Last edited:
The Teensy LC only has 8 kilobytes (8,096 bytes) of read/write memory and 62 kilobyes of read-only memory to hold the program. The Teensy 3.2 has 64 kilobytes of read/write memory and 256 kilobytes of read-only memory to hold the program. You are going to have reduce a lot of your static and global variables to fit in the available read/write memory. Note, you will need additional memory at runtime for the stack and the heap.

In particular, there are the lines:

Code:
#include <OctoWS2811.h>

const int ledsPerStrip = 120;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

The two arrays want to allocate 5,760 bytes, and the library also needs to allocate buffers for USB, etc. If you reduce ledsPerStrip to 64 it might release enough memory to work (going lower would be even better).
 
The Teensy LC only has 8 kilobytes (8,096 bytes) of read/write memory and 62 kilobyes of read-only memory to hold the program. The Teensy 3.2 has 64 kilobytes of read/write memory and 256 kilobytes of read-only memory to hold the program. You are going to have reduce a lot of your static and global variables to fit in the available read/write memory. Note, you will need additional memory at runtime for the stack and the heap.

In particular, there are the lines:

Code:
#include <OctoWS2811.h>

const int ledsPerStrip = 120;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

The two arrays want to allocate 5,760 bytes, and the library also needs to allocate buffers for USB, etc. If you reduce ledsPerStrip to 64 it might release enough memory to work (going lower would be even better).
 
Dang...
What about I add bgr&brg config or are those config bits reserved for something.

(My strip I'm testing is brg)
 
I'd really prefer to leave the examples as-is. The memory limit can be documented on the web page, after Teensyduino 1.35 is released.

Perhaps an ifdef, or a maybe a whole separate example for LC? I think it's always good to have a working example, so users have something to try before they start writing their own code.
 
Status
Not open for further replies.
Back
Top