For grins, try this instead of TOGGLE...
Using that method to set the LEDs, you can dispense with the pause loop and select a higher bit in the ledxcount variable to slow down the blinking.Code:':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 'Hserin with Darryl Taylor's Instant Interrupts ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ' Program to echo incoming serial data ' Baudrate : 9600 Baud ' MCSP and MPASM, LabX-2, Microcodeloader, PBP2.50 ' Using PIC 18F2525 @ 4MHZ and bootloader ' Using internal USART and MAX232 to interface to Hyperterminal on PC DEFINE LOADER_USED 1 DEFINE OSC 4 DEFINE HSER_RCSTA 90h ' enable serial port, define HSER_TXSTA 24h ' enable transmit, define HSER_SPBRG 25 ' set baudrate to 9600 DEFINE HSER_CLOERR 1 ' automatic clear overrun error TRISC = %10000000 ' PORTC.7 is the RX input, PORTC.6 is the TX output ' Serial communication definition ' =============================== ' ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: INCLUDE "MODEDEFS.BAS" ' Include Shiftin/out modes INCLUDE "DT_INTS-18.bas" ' Base Interrupt System INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ' Variable definition ':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty) TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full) led var PORTB.0 led1count var byte led2count var byte led1 var PORTB.1 led2 var PORTB.2 holdoff var word SerialData var byte clear '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RX_INT, _Getbytes, PBP, no endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE RX_INT ; enable RX_INT interrupts '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) ' Subroutine to slow loop down some and toggle heartbeat '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) Mainloop: for holdoff = 1 to 1000 pause 1 next holdoff led1count = led1count + 1 led = led1count.0 'toggle led every loop for heartbeat goto Mainloop '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) 'ISR for RX_int interrupt '((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))) Getbytes: While RCIF = 1 ' clear the buffer HSERIN 100,error,[Serialdata] ' take it hserout [serialdata] ' send it Wend led2count = led2count + 1 led2 = led2count.0 'led to confirm program went to RX ISR @ INT_RETURN error: Toggle led1 @ INT_RETURN end




Bookmarks