;This SX28 code demonstrates setup and use of MIWU pins (Multi-Input Wake-Up). ;This code is written for the SX28 with a date code of AB9921AA (or later) ;and requires the SXKEY28L.exe software for assembly and programming. ;To configure MIWU Mode, the Wake-Up Enable and Wake-Up Edge registers must be set and the Wake-Up ;Pending register must be cleared. It is important to clear the Wake-Up Pending register at ;initialization as well as during the interrupt since the SX will not trigger any additional ;interrupts on that pin unless the corresponding bit is clear. The Wake-Up Pending register ;defaults to all ones ($FF). NOTE: The SX will not trigger an I/O pin interrupt if the SX-Key is ;single-stepping or walking during debug mode. Running or polling during debug mode will allow ;triggering of these interrupts, however. ;This source code can be tested in the SX-Key Demo Board. Simply select Debug from the Run menu. ;After it has downloaded and the Debug screens appear, click on the Poll button to run the code in ;polling mode. Try pressing any of the four buttons on the Demo Board while watching the RB register. ; you should see the corresponding bits change (indicating the detection and clearing of the edge). ;If this code is Run (instead of Polled), it will run at full speed until a button is pressed. DEVICE SX28L,OSC4MHZ,TURBO RESET Start FREQ 4_000_000 hold equ $08 ;Allocate wakeup status variable ORG $00 Start MOV M,#$09 ;Mode=allow Wake-Up Pending access MOV !rb,#%00000000 ;Perform swap between W and WKPND_B (Clear WKPND_B) ;Now W holds Wake-up Pending status, and cleared all flags in the pending register. MOV !ra,W ;Output switch value to port A MOV hold,W ;Save wakeup status in hold SNB hold.0 ;Copy bit 0 to bit 6 in regB (status LED). CLRB rb.6 SB hold.0 SETB rb.6 ;Wake-Up Enable Configuration MOV M,#$0A ;Mode=Wake-Up Edge configuration MOV !rb,#%11111111 ; port B[7:0] bits for falling edge MOV M,#$0B ;Mode=Wake-Up Enable configuration ; MOV !rb,#%11110000 ; port B[7:4] to normal, B[3:0] to Wake-Up Enable MOV !rb,#%11110100 ; port B[7:4,2] to normal, B[3,1:0] to Wake-Up Enable MOV M,#$0E ;Mode=pullup configuration MOV !ra,#$FF ; port A=enable pullup resistors MOV M,#$0F ;Mode=direction configuration MOV !rb,#%00001111 ; port B[7:4] to outputs, B[3:0] to inputs MOV !ra,#0 ; port A=output mode (only low 4 bits in SX28) MOV M,#$09 ;Mode=allow Wake-Up Pending access MOV !rb,#%00000000 ; Clear Wake-Up Pending (WKPND_B) Main SLEEP ;Enter low power sleep mode NOP ; Allow to settle down JMP Main ;Hang here except for wake up interrupts