Menu

Smartpin variable pulse stream

Another useful smartpin mode is outputing a number of pulses with controlled high and low duration.
In this example we output 16 pulses with a high/low duration of 40us and 20us calculated from a 300MHz clock.
Then we wait for the smartpin to acknowledge and output 3 pulses. P50 is used as a reference.

This is it in one line of code (50 HIGH first for scope. The ,,, are just for reability )
48 PIN ... 12000 6000 HILO ... 50 LOW ... 16 PULSES ... WAITPIN ... 3 PULSES ... 50 HIGH

Let's break that one-liner down
First off, my clock is 300MHz so 40us= 12000 and I specify P48 as the target smartpin.
HILO takes high and low count and sets up the Smartpin, so I expect 40us high, 20us low
LOW drives P50 low.
PULSES writes wypin with that value (just an alias) to generate 16 pulses of set timing
WAITPIN waits for smartpin ack
3 more PULSES without any other changes
HIGH drives P50 high to indicate that the code has completed (although the smartpin is still busy)


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.