I have trouble with using RCINT. I am using a bluetooth device to transmit data to the Basic Atom 28 Pin microcontroller, and I want to use the RCINT interrupt to use the received data in my program. Can any one help me find a way to do this?
I am using the Bot Board 2 that I got with the Lynx 6 robotic arm, and the bluetooth is sending the data to the board through Pin 15.
I have read the datasheet for the pic and I’ve tried many different ways to use the RCINT interrupt, but haven’t been successful.
We are going to need example code and concise questions. There is a sticky on using the interupts. Did you check it out? lynxmotion.net/viewtopic.php?t=3496
I have looked at that page, but it does not help me. I am using a Basic atom 28 pin (not PRO).
The problem that I am having is that when I have the following code:
ONInterrupt RCINT, inter
ENABLE RCINT
sethserial h9600
main
goto main
inter
temp=RCREG
debug[dec temp]
resume
the program will never jump into the interrupt routine and will never get the data from the RCREG.
if it is possible can you provide me a sample code that uses RCINT and RCREG, and which pin would be suitable to transmit data to the bot board 2?
I have done a reasonable amount of interrupt processing on the PRO, but not on the basic Atom, but I think I saw a couple of threads covering some of this recently.
In general the OnInterrupt and Enable basic commands simply direct the basic that IF an interrupt of that type happens, then your code will be called. It however does not set up all of the appropriate registers on the PIC micro to actually generate the interrupts. I believe that you need to set the appropriate bits in the INTCON registers and maybe several others as well. (I am not an expert on the PIC).
Also I am not sure if you can mix using the RCINT interrupt with the hardware serial support as I believe that HSERIN uses the underlying hardware interrupts and the like for it’s own processing. It also has it’s own buffer, that it stores the input characters into. So my guess is you can either use the HSERIN and HSERSTAT to process your input or you can implement your own.
As a side note: I always shy away from things like debug or serout, etc while processing an interrupt as other interrupts may be held up…