![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
gerhard Guest
|
Serial port and Interrupts |
Posted: Sun Apr 04, 2004 2:34 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: Serial port and Interrupts |
Posted: Sun Apr 04, 2004 2:46 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|