wouterk
Joined: 03 Jun 2009 Posts: 1
|
PIC 18F242 #INT_RB problem |
Posted: Wed Jun 03, 2009 9:31 am |
|
|
Hello,
Excuse me for my bad english, it's not my native language
I am using a PIC 18F242 for a current school project.
I need two serial ports, driven on interrupts. This is no problem with the hardware RX and TX, I just use #INT_RDA for that one.
But for the software serial port I can't do this.
So my idea was to use #INT_RB for this.
But as soon as I enable the RB interrupt the program gets stuck in this interrupt (because of a getc()-statement). As soon as I send a character on the software RX pin it will jump out of the interruptl.
But I only want it to go to this interrupt when it receives data.
Is this possible? or should I solve this problem in a different approach?
Also, can I leave the programmer on pin B6 and B7 while testing this?
Thanks in advance,
Wouter.
Code: | // Microcontroller header file
#include <18F242.H>
// Microcontroller instellingen
#device ADC=10
#fuses HS, NOWDT, NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=BT, ERRORS)
#use rs232(baud=2400, xmit=PIN_B4, rcv=PIN_B5, stream=RFID, ERRORS)
#use fast_io (a)
#use fast_io (b)
#use fast_io (c)
void main(void)
{
set_tris_a(0x2F); //xx10 1111 analog-input
set_tris_b(0xF1); //1111 0001 soft-serial & ext_int button
set_tris_c(0xC0); //1000 0000 hardware-serial
port_b_pullups(TRUE);
enable_interrupts(GLOBAL);
enable_interrupts(INT_RB);
while(true)
{
fprintf(BT,"mainloop");
}
}
#INT_RB
void RFID_TAG(void)
{
fprintf(BT,"interrupt");
disable_interrupts(INT_RB);
test = fgetc(RFID);
fprintf("received data= %c" ,test);
enable_interrupts(INT_RB);
} |
|
|