Shop OBEX P1 Docs P2 Docs Learn Events
Pulsing object here — Parallax Forums

Pulsing object here

Graham StablerGraham Stabler Posts: 2,510
edited 2006-08-10 15:23 in Propeller 1
I posted this in a thread on using waitcnt in assembly but thought it might be of more general use as it shows how to do several things I didn'tknow how to do before I wrote it.

The object takes a pin number an on-time and an off-time in clock cycles and produces pulses on that pin with those parameters. There are also methods to modify the times as it runs.

It demonstrates:

* an assembly based object
* passing a pointer to global variables in main ram to the cog
* accessing those variables within assembly
* changing those variables with other methods and from other cogs

The demo program is a simple texted based interface that can output to a TV or VGA (with suggested modifications). It is really easy to knock up programs that will produce PWM etc by setting the on-time+off-time = period and then incrememting one as you decrement the other.

Its really simple actually but I hope my copius comments will help beginners as they helped me when writing it.

Cheers,

Graham

p.s. I cleaned out some random code from the previous version I posted.
Sign In or Register to comment.