Hello folks,
Name here is Dwayne, I am very much a neophyte to the PIC chips, and trying to learn them... I used to program philips chips, and the transition is quite a bit different.
Through trial and error, and much help from a few folks out there, I have finally compiled the following Code for the 12f675 chip.
Could someone take a look at it, can check it out for possible errors that I may not know of? Especially on the pin groundings and switches?
I am accomplishing the following;
;When chip is started
;immediately take pin1a and ground it. (This activates the battery ;backup) .
Loop:
Begin Delay for 5 to 7 min.
;following 3 lines is a press of a switch
ground another pin1b.
Delay for 1/2 second.
unground same pin1b.
Delay for 1 min
Unground first pin1a (this cancels battery backup).
****if power is still active do the following 4 lines ****
counter++;
if(counter==3)unground pin2a (KILL power totally to chip)
delay 1 min.
Goto Loop;
*******************************************
If chip loses power, start at beginning of loop.
Seconds var byte ' 0-59
Minutes var byte ' 0-5
counter var byte ' 0-3
counter=0;
Loop:
;Battery backup pin toggles base of transistor to insure 5 volts
Low GPIO.3;
For Minutes=0 to 6
gosub Delaymin
Next Minutes
;the following routine acts like pressing a button..
;grounds pin 4 to ground (direct short to ground)
Low GPIO.4;
Pause 250;
;ungrounds pin 4
High GPIO.4;
gosub Delaymin
;takes battery backup off. If no power, chip stops.
;and starts over again when power is applied to it.
;if not, chip reassures battery backup for up to 3 times.
High GPIO.3
counter=counter+1
if counter=3 then Low GPIO.3
gosub Delaymin
goto Loop
Delaymin
For Seconds=0 to 59
Pause 1000
;flashing light for reference
toggle GPIO.5
Next Seconds
return
Bookmarks