CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC 18F242 #INT_RB problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
wouterk



Joined: 03 Jun 2009
Posts: 1

View user's profile Send private message

PIC 18F242 #INT_RB problem
PostPosted: Wed Jun 03, 2009 9:31 am     Reply with quote

Hello,

Excuse me for my bad english, it's not my native language Wink

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);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 03, 2009 10:52 am     Reply with quote

It would be a lot easier if you use Pin B0 (INT_EXT) for the Rx.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group