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

int_rda

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



Joined: 31 May 2005
Posts: 2

View user's profile Send private message

int_rda
PostPosted: Tue May 31, 2005 11:31 am     Reply with quote

Hi All,

I'm having trouble with the rda interrupt. I checked the communication with this program:
Code:
// type of pic
#include <16F628.h>
// osc., no watchdog, power up timer,no protect
#fuses XT,NOWDT,PUT,NOPROTECT
// progr id V 100
#id 0x0100
// 4 MHz clock
#use delay (clock=4000000)
#use rs232 (baud=9600, parity=N, bits=8, rcv=PIN_B1)

#define LED PIN_B7

short select=FALSE;

void main(void){
   while(TRUE){
      if (kbhit()){
         getc();
         if(select){
            select = FALSE;
            output_low(LED);
         }else{
            select = TRUE;
            output_high(LED);
         }
      }
   }
}

It worked so I changed it to:
Code:
// type of pic
#include <16F628.h>
// osc., no watchdog, power up timer,no protect
#fuses XT,NOWDT,PUT,NOPROTECT
// progr id V 101
#id 0x0101
// 4 MHz clock
#use delay (clock=4000000)
#use rs232 (baud=9600, parity=N, bits=8, rcv=PIN_B1)

#define LED PIN_B7

short select=FALSE;

#int_rda
void rda_isr(void){
   int receive;

   receive=getc();
   if(select){
      select = FALSE;
      output_low(LED);
   }else{
      select = TRUE;
      output_high(LED);
   }
   return;
}

void main(void){
   enable_interrupts(global);
   enable_interrupts(int_rda);
   while(TRUE){
      delay_ms(1000);
   }
}

And that code did not do what I expected.
Does anybody know what I'm doing wrong?

Thanks,

Rob.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Tue May 31, 2005 1:44 pm     Reply with quote

Confirm that the compiler is using the hardware UART. Since you didn't specify the transmit pin in your #use rs232 statement I'm not sure what the compiler will generate. Specify the appropriate pin for transmit, PIN_B2 I believe.

Then check your LST file to see if the code generated for your getc and kbhit is using the UART registers or if it is calling bit-banging code.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
Guest
Guest







PostPosted: Tue May 31, 2005 2:05 pm     Reply with quote

Yes, perhaps you are defaulting to a software interrupt. Try to ensure the hardware USART is used by explicityly giving proper Rx and Tx pins. Try this

#USE RS232(BAUD=9600, XMIT=PIN_B2, RCV=PIN_B1, ERRORS)
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Tue May 31, 2005 11:17 pm     Reply with quote

You might be missing characters when you are in the delay_ms(1000).

What kind of missbehavior are you getting?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 31, 2005 11:41 pm     Reply with quote

No, it's because of what the others suggested -- If you only define
one hardware pin in the #use rs232() statement, the compiler inserts
a soft UART and there is no rda interrupt. See these posts:
http://www.ccsinfo.com/forum/viewtopic.php?t=17803
http://www.ccsinfo.com/forum/viewtopic.php?t=22028
RodeKlu



Joined: 31 May 2005
Posts: 2

View user's profile Send private message

PostPosted: Wed Jun 01, 2005 5:54 am     Reply with quote

I added the transmit line and it worked fine. The other posts answer my question if I could still use the transmit line in another way. I can.

Thanks for the help,

Rob.
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