I built a 4R70W Ford transmission controller a few years back and its been working flawlessly. Using a 20x2, measuring input pulses from a speed sensor over a set amount of time. That time give me a 1 to 1 ratio for pulses to MPH. On 2 occasions the controller locked up and defaulted in what ever the last gear was, 4th gear so far. The only thing I can think of that would cause to code to stop running the main loop is if it get stuck in the interrupt routine. What happens if the timer overflow happens while the interrupt routine in servicing an input pulse or both an input pulse and timer overflow happen within the same machine cycle?
I've include just the header info and the interrupt routine. Is there a better way to read the input pulses and have the timer overflow flag capture the time?
thanks Ryan
I've include just the header info and the interrupt routine. Is there a better way to read the input pulses and have the timer overflow flag capture the time?
thanks Ryan
Code:
'4R70W beta3.5.4bt PIXACE 20x2 6 Aug, 2014 ((1243 bytes flash), 38 bytes of RAM, 7 bytes PROM)
eeprom 0, (1,255,2,1,3,182,3) '511,513,950,3
setfreq m8 'set ferq to 8MHz
let dirsc = %00110000 'set portC as inputs C.5 PWM output
let dirsb = %11111110 'set portB as outputs, B.0 HINT input
let adcsetup = %0000001000000000 'set ADC ports 9, c.1
hintsetup %00000010 'falling egde trigger on B.0 input
setintflags or %10000010, %10000010 'hardware interrupt INT1, Timer over flow flag
hsersetup b115200_8, %00001 'enable serial io for bluetooth coms background receive %00001
hpwm pwmdiv16, 0, 0, %0010, 249, 250 '500 hz 50% = 500 1000 = 100%
'*******INTERRUPT ROUTINE********************************
interrupt:
if toflag = 1 then 'check if interrupt was caused by toflag.
settimer off 'turn off timer
mph = w15 'load w15 to MPH
let w15 = 0 'clear w15 value to zero
let toflag = 0 'clear over flow flag
elseif w15 = 0 then 'on first hardware input w15 will still be zero
inc w15 'increment w15
let hint1flag = 0 'clear hardware flag
let timer = 65535 'preloads timer to overflow and set toflag when minor ticks finish counting
settimer 54535 'enable timer 0.352 seconds
else
inc w15 'increment w15
let hint1flag = 0 'clear hardware flag
endif
setintflags or %10000010, %10000010 'hardware interrupt INT1, Timer over flow flag
return