Hi
My recent post on power saving has unfortunately notv produced a solution to my problem and I have therefore tried a different approach which has produced problems which I hope are easier to solve .
My requirement is for a progam which can produce two flashing patterns for an led on portb.7 selected by a pushbutton on portb.0 ( For a model lighthouse a friend is building) I would like to use a single button which can sequence thru' OFF -Pattern 1 - Pattern 2 -Off it is intended that each of the two patterns will run for a finite time (or number of sequences) and then shut down. Alternatively a button press during the sequence can cause shut down. I am very unsure about the use of interrupts but after studying melabs example I have produced the attached program:
Whilst the program enables me to select the next sequece when the current sequence has completed it will not interrrup the sequence if I wish to move to shutdown. Can anyone tell me why and how perhaps I could achieve this ?
An ancillary question is ---- Since I want to shut down the circuit indefinately and I understand the the sleep command has a maximum of about 18 hours do I have to let it wake briefly and execute a routine or am I correct in understanding that by using @sleep I can get an indefinite shutdown . Any help would be greatly appreciated.
[@ DEVICE pic16f628a,intrc_osc_noclkout,mclr_on
led Var PORTB.7
x var byte
delay var byte
OPTION_REG = $7f ' Enable PORTB pullups
On Interrupt Goto myint ' Define interrupt handler
INTCON = $90 ' Enable INTE interrupt
main:
for x = 1 to 10 ' First led flashing pattern
low portb.7 '
pause 200 '
high portb.7 '
pause 200 '
next x '
sleep 500 ' sleep after completing first pattern
for x = 1 to 10 ' Second led flashing pattern
low portb.7 '
pause 500 '
high portb.7 '
pause 500 '
next x '
sleep 500 'sleep after completing second led flashing pattern
sleep 500 ' just sleep
goto main: 'return to first vflashing pattern
disable ' this bit copied from example melabs program
myint: ' but I havent a clue what it means and the
delay = 200 ' picbasicpro manual fails to enlighten me
INTCON.1 = 0 '
resume '
End
]
Bookmarks