Bit Banging from TAQOZ
![frank freedman](https://forums.parallax.com/uploads/userpics/236/nG0JGZG7UQT41.jpg)
in Propeller 2
@"Peter Jakacki", @JonnyMac and others. This may seem a lazy post, but things have been busy for a while and totally upended a couple weeks ago, so I probably missed it in the threads. I am looking for how to bit bang a string of data bits, for example the neopixel ring or other things from the P2 using TAQOZ. If anyone knows of a thread detailing how it can be done, with an example or two I would appreciate it. Thanks to all.....
Comments
I don't know how to do this in TAQOZ, but I can show you how I do it with inline PASM2; if Peter hasn't yet built in WS2812 support, you may be able to translate this.
Thank you Jon.
Between what you put up and what I just found in Peter's TAQOZ doc, I may be able to figure this out. Let y'all know how it turns out.
@"frank freedman" Sorry, I've been totally tied up for the past week. This kind of bit banging is fairly easy and assuming you P2 clock is 200MHz, you could try this quick and dirty one-liner.
: PIXELS ( src bytes -- ) L ADO I C@ 12 COG@ 8 FOR H H H LSBOUT NOP L NEXT 2DROP LOOP ;
The main thing with timing is to remember the decode in the pixel is fairly simply and the lohi is necessary to clock a bit using a delay which I breakdown to bit period into 3 parts: a high, the data bit, a low.
If you want top call this continually just remember that it needs at least 50us before the start of a new transmission.
This above just uses a byte buffer, so 3 bytes per pixel but if you want a long for each pixel then it is simply this:
: PIXELS ( src longs -- ) L ADO I @ 12 COG@ 24 FOR H H H LSBOUT NOP L NEXT 2DROP 4 +LOOP ;
With 8 Neopixels on P8 and a the pattern held in BUFFERS I would type
8 PIN BUFFERS 24 PIXELS
I have the Neopixels running in Tachyon, so I may just get to check out some code later on and post that here.
Thank you Peter. No worries, no rush. Hope all is well where you are. Got shown Forth in the early 80's, not sure what to do with it then, now starting to make sense. Also now a faster way to make use of the P2 for now.
BTW, I'm just about to update the binary and other files. I also added a simple WSTX instruction which takes a buffer address and byte count just as it did in Tachyon. On my Neopixel strip the order is green,red,blue. At the start of each transmission it calculates the timing required for the current clkfreq as well. Just set the pin or pin range that you want.