My goal is to connect 2 pics together with Zigbee. I bought a Dev. kit from http://www.digi.com/ for $99.00. I'd like to use the Hardware serial port in the pic (18f2525) to communicate with the Zigbees so I'm trying to learn the ins and outs of Hserin, Hserout.
I put together this little collection of snippetts to echo characters back to Hyperterminal. The echo seems to work fine when I send one character or 20. The part that has me stumped is:
1) the Mainloop doesn't run. No Heartbeat.
2) The echo part of the ISR seems to work as expected but the Led2 doesn't toggle as expected. (on with the first byte sent, off with the second on with the third etc....).
I've been thru "TFM" on the Eusart and tried many different register settings many times but the solution hasn't jumped out at me yet.
I've Hserin with and without timeouts.
I've tried a pullup on RC7.
I've tried a pulldown on RC7.
So, as always, I would greatly appreciate a little nudge in the right direction. Not spoon feeding, just a nudge.
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 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 toggle led '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 toggle led2 'led to confirm program went to RX ISR @ INT_RETURN error: Toggle led1 @ INT_RETURN end




Bookmarks