SetPin(GPnn), FIN query


Author Message
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5994
Posted: 08:26am 27 Aug 2023      

@Carl,

You had another question I did not answer. About assigning a pin with SETPIN.

When you want PIO to control a pin, then you must inform MMBasic to reserve it for PIO. When you want PIO to only read the pin status (high or low) you do not need to do that. In fact, it can be used to your advantage.

The above program reads the pin status of GP0.
You can add 2 lines to the program so MMBasic uses the same GP0 pin for PWM

SETPIN gp0,PWM
PWM 0,5000,50


Now the PWM generates a 5000Hz test tone that PIO measures.

The reverse can also be done. Use SETPIN to assign a pin to PIO, make PIO generate a signal, and have MMBasic read the pin status with a=PIN(gpxx).

Both above cross-functions are used in the PicoMite VGA LA (logic analyzer) that uses the PIO to sample the analyzer signals, and MMBasic to control and display.
Edited 2023-08-27 18:29 by Volhout