;======================================================================= ;Assembly Language Tutorial for the SX Microcontroller ;Program 7.7 ;======================================================================= device sx28l,oschs3 device turbo,stackx,optionx IRC_CAL IRC_SLOW reset start_point freq 50000000 ; 50 MHz org 8 microlow ds 1 microhi ds 1 millilow ds 1 millihi ds 1 seconds ds 1 ticker ds 1 tmp ds 1 org 0 isr ; check for pending key mov tmp,M ; save M register mode $9 clr w mov !rb,w ; exchange w and pending and w,#1 ; test low bit jz rtccisr not ticker ; invert ticker mov M,tmp ; restore M iret rtccisr mov M,tmp inc microlow snz inc microhi cjne microhi,#$03,iout ; blink every $03e8 periods cjne microlow,#$e8,iout ; 1000 uS already! clr microlow clr microhi ; roll millisecond inc millilow snz inc millihi cjne millihi,#$03,iout cjne millilow,#$e8,iout ; 1000 ms! clr millihi clr millilow test ticker jz notick xor rb,#$FF ; toggle LEDs notick inc seconds iout mov w,#-50 ; interrupt every 1uS retiw start_point mov !rb,#$01 ; 7 outputs areset clr microhi clr microlow clr seconds clr ticker ; set RTCC to internal clock 1:1 ratio mov !option,#$88 ; no prescale ; set port B detect falling edge mode $A ; select edge mov !rb,#$FF mode $B ; enable interrupt on pin 0 mov !rb,#$FE loop jmp loop