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 support@ccsinfo.com

Serial port and Interrupts

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







Serial port and Interrupts
PostPosted: Sun Apr 04, 2004 2:34 pm     Reply with quote

Hello,

I am using the PIC18F8720 (MPLAB6.40, CCS PCH (3.148)) and have the following problem:
I use the RS232 port to control a graphic display. When do not use interrupts everything works fine, but as soon as I enable int_rb I get garbage on the display (the whole time).

Here is the code:
Code:

#include <18F8720.h>
#fuses  HS,NOWDT,noprotect,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=pin_d5,rcv=pin_d4,stream=a)

#int_rb
void rb_isr()
{
   putc(27,a);
   printf("ZL");
   putc(150,a);
   putc(150,a);
   printf("Some text");
   putc(0,a);
}

void main()
{
   enable_interrupts(global);
   enable_interrupts(INT_RB);

   putc(27,a);
   printf("DL");
   
   putc(27,a);
   printf("ZL");
   putc(100,a);
   putc(100,a);
   printf("test");
   putc(0,a);

   while(true)
   {}   
}


Any suggestions?

Gerry
Ttelmah
Guest







Re: Serial port and Interrupts
PostPosted: Sun Apr 04, 2004 2:46 pm     Reply with quote

gerhard wrote:
Hello,

I am using the PIC18F8720 (MPLAB6.40, CCS PCH (3.148)) and have the following problem:
I use the RS232 port to control a graphic display. When do not use interrupts everything works fine, but as soon as I enable int_rb I get garbage on the display (the whole time).

Here is the code:
Code:

#include <18F8720.h>
#fuses  HS,NOWDT,noprotect,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=pin_d5,rcv=pin_d4,stream=a)

#int_rb
void rb_isr()
{
   putc(27,a);
   printf("ZL");
   putc(150,a);
   putc(150,a);
   printf("Some text");
   putc(0,a);
}

void main()
{
   enable_interrupts(global);
   enable_interrupts(INT_RB);

   putc(27,a);
   printf("DL");
   
   putc(27,a);
   printf("ZL");
   putc(100,a);
   putc(100,a);
   printf("test");
   putc(0,a);

   while(true)
   {}   
}


Any suggestions?

Gerry

You enable the port b _change_ interrupt. Then you never read port b, so this interrupt will never be reset. The interrupt routine will be continuously called...
To use the RB interrupt, _read_ port B before enabling it, and read it again inside the interrupt handler. The handler will then be called only when the port changes.

Best Wishes
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