Sunday, 25 April 2010

Programming

setint %01000000,%01000000

let w0 = 1

main:

do

readadc 1,b1
readadc 2,b2

select case b1
case 0 to 80
high 3
case 80 to 155
low 3
endselect

select case b2
case 0 to 100
high 1
case 80 to 155
low 1
endselect

loop while w0 = 1



do

high 1,3
low 2,4

loop while w0 = 0


goto main


interrupt:
if w0 = 0 then
let w0 = 1
else w0 = 0
endif
setint %01000000,%01000000
pause 1000
return





I have elimnated splitting the two programs into two different routines, since I learned that the interrupt need a 'return' function to go back to the main program. This has made me change the program around a little so that it works using 'do-while' loops. I assigned variables that will tell the program when to repeat which routine until pin6 goes high and interrupts changing its 'do while' conditions to move to the second program routine depending on the variable.

now that I have figured how to switch between one program to the other. I am going to change the second program to run how we need it to.

1 comment:

  1. I don't necessarily feel you needed to get involved in interrupts unless your programme cycle was very long. A simple check for the switch would probably have done as switching between formats was not super time critical.

    ReplyDelete