Hi Jeff,
I have not used Pic Basic Compiler for almost 10 years but here are some comments and items to check/change to get you going.
Code:
SYMBOL ANSEL = $9F '$19 IS ANSEL REGISTER
POKE ANSEL, 0 'MAKE PIN DIGITAL, NOT ANALOG
this looks good except your comment is for CMCON not ANSEL (see below)
Code:
SYMBOL ADCON0 = $1F 'TURN OFF A/D ON PIN4. (DEFAULT IS ON)
POKE ADCON0, 254 '$1F IS ADDR OF A/D REGISTER. 10011111 (7)
you do not need to fiddle with ADCON0 unless you want to use the A2D module. You should leave these two lines out. As it stands now, these two lines set up the A2D to acquire AN3 using a reference voltage on pin GP1, which might be messing you up. The pins do default to analog but changing them to digital is accomplished with ANSEL and CMCON.
You need to disable the comparators so add something like this
Code:
SYMBOL CMCON = $19 '$19 IS CMCON REGISTER
POKE CMCON, 7 'MAKE PIN DIGITAL, NOT ANALOG
Code:
SYMBOL TRISA = $85 'SETUP PINS DATA DIR I/O
POKE TRISA, 255 'MAKE DATA I/O GP0 AN OUTPUT, GP1 AN INPUT
'AND MAKE GP1 AN INPUT (ALL OTHERS ARE OUTS)
Here the poke 255 is actually making everything inputs. If you want everything to be inputs except GP0, then poke 254
Code:
symbol PORTA = $05 '$05 IS OUTPUT DATA REGISTER
POKE PORTA, 0 'TURN OFF ALL BITS
turns off all outputs so okay
Code:
Loop1: PEEK PORTA, BIT0 'COPY PORTA REG, PUT IN VARIABLE B0
you need to peek porta into a byte sized variable. Try PEEK PORTA, B0 as noted in your comment
Code:
IF BIT0 = 1 THEN LOOP1 'WHEN BUTTON IS PUSHED, INPUT GOES LOW
this does check bit 0 of B0 but you wanted GP0 to be an output? Maybe you want to check the bit where your switch is connected.?
Code:
loop2: High 0 'Turn on LED connected to GP0
Pause 500 'Delay for .5 seconds
Low 0 'Turn off LED connected to GP0
Pause 500 'Delay for .5 seconds
Goto loop2 'Go back to loop and blink LED forever
this trap looks good.
One last comments - Ski is correct, it is strange to rename the GPIO port to PORTA. Consider changing all PORTA refs above to GPIO. The same goes for TRISA - change to TRISIO
reply back with progress for more help
Bookmarks