Useful trick with SPIOUT

Buzby

Senior Member
Hi all,

I need to toggle a pin a variable number of times, as quick as possible.
Experimenting with different methods I discovered this trick with SPIOUT.

Code:
spiout c.1,d.7,0, (0 / 67)  ' make 67 clock bits
c.1 is the 'clock out' pin, which is what I'm interested in.
d.7 is the 'data out' pin, which is just a dummy, because I don't need data.
The first 0 is the mode, it sets the idle level.
The second 0 is the data to send, and as I have no data it could be any value.

The clever bit is the '/ 67', this causes c.1 to toggle 67 times, nice and quickly.
The value can be from 1 to 255.

I not seen spiout used like this before, and it might not be my final solution, but it might be useful to someone.

Cheers,

Buzby
 
Top