forgot to add I have tried 4 ways to implement this , none of which produces any error .
the subroutine below is run 1/sec in a working packet radio system with heaps or interrupts ,
no sign of sky falling yet
ps the result is displayed on a glcd using my glcd include as previously described in this forum
Code:
w0 var word
Report var byte[4]
albo var byte[4]
I var byte
alberto:
random w0
albo[0] = w0
random w0
albo[1] = w0
random w0
albo[2] = w0
w0=0
for i =0 to 2
w0=w0+albo[i]
next
crc: ; label to examine listing if required
;method 0
albo[3] = ~w0
Report[0] = albo[3]
;method 3
@ NOT?WB _w0,_Report+3
;method 2
Report[2] = w0 //256
Report[2] = ~ Report[2]
;method 1
asm
CHK?RP _w0
MOVF _w0,W
CHK?RP _Report
MOVWF _Report +1
COMF _Report +1,F
RST?RP
ENDASM
ecrc:
IF (Report[0]-Report[1])-(Report[2]-Report[3]) THEN
ARRAYWRITE BUFF,["The sky is falling",0]
led_cnt=KEY_BEEP_TIME ; set off the alarm
led_times=2 ; twice for good measure
ELSE
ARRAYWRITE BUFF,[#Report[0]," ",#Report[1]," ",#Report[2]," ",#Report[3],0]
endif
GLCD_CLR 0,43,100,8
GLCDC 1 ,43
GLCDSTR BUFF
return
Bookmarks