Hi,
Paul's reply is very important. Also do you have pull up or pull down resistors on your inputs?
You can save some typing by setting up your ports like this:
TRISA = %00000111 '1 = input 0 = output
TRISB = %11000000
TRISC = %00000000
Just looking at your Main program, "If tpin = 0 then main" says if the input pin is grounded or low just loop here until it's high. If it's high then pulse the LED on and off until the tpin is low again. Without plugging this program into a board here it should seem it would work BUT as Paul said what have you done with pin 1 and did you set ADCON1 to 7.
In your "hardware setup" you have CMCON = 7 'disable adcs, porta = digital.
All "CMCON = 7" does is disable the comparators.
"ADCON1 = 7" disables the analog ports making them digital.
Pin 1 is the MCLR input and needs to be made high through at least a 1K resistor. You should also have .01uF capacitors across the + and - power pins as close as possible and also one between the MCLR pin and ground.
I'm going to work now so try these things out and see if your PIC doesn't work better.
You're only learning now!
Have a nice day!
BobK
Bookmarks