new SetDigitalIO module - help wanted

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Jerry Messina
Swordfish Developer
Posts: 1486
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

new SetDigitalIO module - help wanted

Post by Jerry Messina » Sat Sep 12, 2015 3:00 pm

I've added some new functions to the SetDigitalIO.bas module, but before I post it on the wiki I thought I'd give folks a chance to try it out/test it with your favorite chip. There's just too many for me to test them all.

New functions include:
- SetAnalogPort() macro that lets you control the analog/digital setting of an individual pin without having to know the register or which way around it works (0 or 1). Includes ANxx pin definitions for most devices.

- SetAllAnalog() sets all pins to analog mode (the opposite of SetAllDigital). This sub is usually sort of redundant since the pins power up in analog mode, but it was handy while I was testing SetAnalogPort so I left it in.

Some examples:

Code: Select all

device = 18F26K22
include "SetDigitalIO.bas"

SetAllDigital()
// change AN1 and AN2 to analog mode
SetAnalogPort(AN1, ANA)
SetAnalogPort(AN2, ANA)

SetAllAnalog()
// change AN2 to digital mode
SetAnalogPort(AN2, DIG)
SetAnalogPort only works with chips that allow individual pin control of the analog/digital port configuration.

If you run across any issues/have any comments (good or bad), drop a note here
Attachments
SetDigitalIO_v2.zip
(5.4 KiB) Downloaded 264 times

Jerry Messina
Swordfish Developer
Posts: 1486
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: new SetDigitalIO module - help wanted

Post by Jerry Messina » Thu Oct 06, 2016 11:29 am

Just FYI in case anyone runs across this post in the future...

I added the analog functions to the V2.1 download available on the SetDigitalIO wiki page

Post Reply