Hello everyone,
I'm trying to make a simple program that will blink a LED on PortB.2. While waits for an incoming character to PortC.7(with max232). My trouble I think is with the command serin PortC.7, T2400, RX and my PortB.2 doesnt blink. I appreciate any help/guide to understand how I can make this work.
mboxCode:CLEAR include "modedefs.bas" 'include serout defines DEFINE OSC 20 OPTION_REG=%10000101 ;Bit 7=1 disable pull ups on PORTB ;Bit 5=0 selects timer mode ;Bit 2=1 } ;Bit 1=0 } sets Timer0 pre-scaler to 64 ;Bit 0=1 } INTCON=%10100000 ;Bit 7=1 Enables all unmasked interrupts ;Bit 5=1 Enables Timer0 overflow interrupt ;Bit 2 flag will be set on interrupt and has to be cleared ;in the interrupt routine. It is set clear to start with. RX var byte ; holds incoming character symbol led1=PORTB.0 symbol led2=PORTB.1 i var byte ;counter Cnt var byte TRISB = %11110000 ;sets the 3 output pins in the B port PORTB = %00000000 ;sets all pins low in the B port TRISC = %10000000 ;Set portC.7 for serial input ON INTERRUPT GOTO INTERUPTROUTINE MAINLOOP: High PORTB.2 For i = 0 to 200 Pause 1 Next i Low PORTB.2 For i = 0 to 200 Pause 1 Next i '''''''''''''''''''''''''''''''''''''''''''''''' IF Cnt=49 then led1=1-led1 pause 100 Cnt=0 endif if Cnt=50 then led2=1-led2 pause 100 Cnt=0 endif GOTO MAINLOOP ;end of loop DISABLE INTERUPTROUTINE: serin PortC.7, T2400, RX 'Receive menu Cnt = Rx ENDINTERRUPT: ; INTCON.2 = 0 ;clears the interrupt flag. RESUME ;resume the main program ENABLE ;DISABLE and ENABLE must bracket the int routine END
Bookmarks