comparison code_part1/OSTC_code_asm_part1/isr.asm @ 343:d5240792be51

BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
author JeanDo
date Sat, 21 May 2011 14:38:56 +0200
parents 2144f19fa1eb
children 797e2ac42d24
comparison
equal deleted inserted replaced
342:06299199dfb9 343:d5240792be51
31 ; Copy a 16bit value from ISR modified registers to main registers. 31 ; Copy a 16bit value from ISR modified registers to main registers.
32 ; 32 ;
33 ; Because the ISR can happend at any time, the read should be redone if bytes 33 ; Because the ISR can happend at any time, the read should be redone if bytes
34 ; changed inbetween. 34 ; changed inbetween.
35 ; 35 ;
36 ; NOTE: Destination might be in any bank, so be BANK SAFE on b 36 ; Trashes: WREG and TABLAT
37 37 ; NOTE: Destination might be in any bank, so be BANK SAFE.
38 SAFE_2BYTE_COPY MACRO a, b 38 ;
39 SAFE_2BYTE_COPY MACRO from, to
39 local retry 40 local retry
40 retry: 41 retry:
41 movf a+1,W ; High byte in W, (CURRENT BANK ONLY) 42 movff from+1,WREG ; High byte in W.
42 movff WREG,b+1 ; and destination. 43 movff WREG,to+1 ; and destination.
43 movff a,b ; Copy low byte. 44 movff from+0,to+0 ; Copy low byte.
44 xorwf a+1,W ; High byte changed ??? (CURRENT BANK ONLY) 45 movff from+1,TABLAT ; another bank-safe read.
46 xorwf TABLAT,W ; High byte changed ?
45 bnz retry 47 bnz retry
46 ENDM 48 ENDM
47 49
48 ;============================================================================= 50 ;=============================================================================
49 uartint: 51 uartint: