This is a set of Radioshack Tri color LED strips. It’s being run by a Beagle Bone Black using an assembler program on the PRU unit on the Beagle. The standard IO on the beagle is too slow to control the lights properly. I think my math might have been a little off since the colors are changing as it feeds the data. They should be rolling but the point is, it does work.
This is the bulk of the important code:
RESET:
//Loop 2400 times which is 4800 instructions 1 inst per 5ns equals a 24us delay
MOV r0, 2400
RESETLP:
SUB r0, r0, 1
QBNE RESETLP, r0,0
SEND1:
//This uses a JUMP to return so timing is off but tolerance says +/- 200ms is okay.
//We used a jump to get here so 10NS total was lost.
SET r30.t14 //Turn pin on
MOV r0, 180 //Loop 180 times which is 2 instructions each so 360 instructions which is 1800ns or 1.8us
SEND1D:
SUB r0,r0,1
QBNE SEND1D, r0, 0 //When it’s 0 then progress
CLR r30.t14 //Turn pin off
MOV r0, 70 //Loop 70 times which is 2 instructions each loop so 140 instructions is 700ns or .7us
SEND1D2:
SUB r0,r0,1
QBNE SEND1D2, r0,0
RET //Jump back to the last issue of CALL which was done to SEND1
SEND0:
//This uses a JUMP to return so timing is off but tolerance says +/- 200ms is okay.
//We used a jump to get here so 10NS total was lost.
SET r30.t14 //Turn pin on
MOV r0, 70 //Loop 70 times which is 2 instructions each loop so 140 instructions is 700ns or .7us
SEND0D:
SUB r0,r0,1
QBNE SEND0D, r0, 0 //When it’s 0 then progress
CLR r30.t14 //Turn pin off
MOV r0, 180 //Loop 180 times which is 2 instructions each so 360 instructions which is 1800ns or 1.8us
SEND0D2:
SUB r0,r0,1
QBNE SEND0D2, r0,0
RET //Jump back to the last issue of CALL which was done to SEND0
After this you can just do CALL SEND1 to transmit a 1 and CALL SEND0 to transmit a 0. A RGB number is 24 bytes. So chain a bunch 24 calls together to get a single light to turn on.
Before I get hounded:
Yes I know I filmed the video the wrong way. Go away, I don’t care. Yes the assembler probably is poorly written. I don’t write assembler for a living and wanted it to be easy to read so no bitwise crud.
Whee!
I get to play around with PRU assembly with the help of this guy's code! \o/
Though doing so has made me realize the need for a very barebones programming language with built-in support for high resolution delays to help with some of the low level command protocols implemented in ICs.











