Hi, I'm currently testing some firmware with an electronic deployment altimeter I've made. However I'm running into a problem with one of my initial loops.
Basically the altimeter is supposed to do nothing but read baseline pressure and wait for input when powered up. It waits for two inputs, arm and mach delay. Arm arms the device at which point it waits for a large acceleration before arming the deployment charges.
Mach delay is a small subroutine that adds a value onto a variable, this variable is used later to specify the number of seconds the device will ignore pressure readings for (the idea is that as the rocket passes the speed of sound the pressure sensor will get some strange readings that it should ignore).
When the delay line is pulled high the program is supposed to add 2 seconds to the delay variable and then beep twice before returning to the start loop. However in practice when I energise the delay line the device beeps twice then continues beeping twice forever. This indicates that after going through the delay loop and going back to the start loop it thinks that the delay line is still high, even when power is no longer applied.
Here is my code:
Code:
start: poke ADCON0 , $91
pause 1
poke ADCON0 , $95
pause 5
peek ADRESH,B0
Peek ADRESL,B1
W6 = W0
W0 = W0 - 50
peek PortB, B2
B3 = B2 & 1
B4 = B2 & 2
if B3 = 1 then beep
if B4 = 2 then delay
goto start
delay: B5 = B5 + 2
high 4
pause 1000
low 4
pause 1000
high 4
pause 1000
low 4
B4 = 0
goto start
I'm not sure where the problem is, clearly either B2 or B4 are not being cleared when they should be or there is something wrong with my peek to portb or my masking of B2.
Anyone have any ideas?
Bookmarks