Mercurial > public > mk2
diff code_part1/OSTC_code_asm_part1/altimeter.asm @ 341:2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
author | JeanDo |
---|---|
date | Fri, 20 May 2011 00:48:30 +0200 |
parents | 8a0bbe43df65 |
children | 797e2ac42d24 |
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/altimeter.asm Fri May 20 00:39:05 2011 +0200 +++ b/code_part1/OSTC_code_asm_part1/altimeter.asm Fri May 20 00:48:30 2011 +0200 @@ -55,8 +55,7 @@ clrf pressureSum+1 clrf pressureCount - movff amb_pressure+0,pressureAvg+0 ; And init first average. - movff amb_pressure+1,pressureAvg+1 + SAFE_2BYTE_COPY amb_pressure, pressureAvg ; And init first average. movlw 4 ; And multiply AVG by 16 to be coherent. altimeter_reset_1: @@ -73,9 +72,11 @@ altimeter_1: ;---- Do a bank-safe 16bit summing ----------------------------------- - movff amb_pressure+0,WREG + SAFE_2BYTE_COPY amb_pressure, lo ; And init first average. + + movff lo,WREG addwf pressureSum+0,F - movff amb_pressure+1,WREG + movff hi,WREG addwfc pressureSum+1,F incf pressureCount ; Increment count too.