![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Eugene Guest
|
2 serial ports with interrupts |
Posted: Tue May 28, 2002 2:52 pm |
|
|
I've written a simple routine to handle 2 serial ports both working on interrupts. The hardware routine works fine. But the software seem to hang up on the getc command.
Initially, It recieves a byte correctly but for some reason the RB_INT re-triggers instantly after it leaves the routine. I've tried to to disable the int right after the getc command and even put a delay in case there was a some kind of garbage but nothing seems to work. Any suggestions would be great.
int t;
#use rs232(baud=19200, xmit=PIN_B6, rcv=PIN_B7, PARITY=N, BITS=8)
#int_rb
soft_serial_isr()
{
t=getc(); printf("S");
putc(t);
}
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7, PARITY=N,BITS=8, ERRORS, ENABLE=PIN_C5)
#int_rda
hard_serial_isr()
{
t=getc(); printf("H");
putc(t);
}
main()
{
enable_interrupts(global);
enable_interrupts(INT_RB | H_TO_L);
do {
} while (TRUE);
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 4645 |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: 2 serial ports with interrupts |
Posted: Tue May 28, 2002 4:26 pm |
|
|
A couple of comments. The H_TO_L define is used for the EXT_INT_EDGE() function and not the enable_interrupts. The following was taken from a device header file:
// Constants used in EXT_INT_EDGE() are:
#define L_TO_H 0x40
#define H_TO_L 0
H_TO_L is defined as 0 so there is no adverse effects. Also the H_TO_L and L_TO_H is only for the external ints. It is not used for the PORT B change int.
Now to the problem at hand. Are you using an RS232 transceiver chip? The RS232 signals are inverted from the logic signals as well as a different voltage range. Could the int be triggered by the stop bit? Since int_rb doesn't care which way the transition occurs, just the fact that one occured triggers the int. You should probably check for the proper transition and pin before calling the getc() function.
Mark
:=I've written a simple routine to handle 2 serial ports both working on interrupts. The hardware routine works fine. But the software seem to hang up on the getc command.
:=Initially, It recieves a byte correctly but for some reason the RB_INT re-triggers instantly after it leaves the routine. I've tried to to disable the int right after the getc command and even put a delay in case there was a some kind of garbage but nothing seems to work. Any suggestions would be great.
:=
:=
:=
:=
:=int t;
:=
:=#use rs232(baud=19200, xmit=PIN_B6, rcv=PIN_B7, PARITY=N, BITS=8)
:=#int_rb
:=soft_serial_isr()
:=
:={
:= t=getc(); printf("S");
:= putc(t);
:=}
:=
:=
:=
:=#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7, PARITY=N,BITS=8, ERRORS, ENABLE=PIN_C5)
:=#int_rda
:=hard_serial_isr()
:={
:= t=getc(); printf("H");
:= putc(t);
:=}
:=
:=main()
:={
:=
:=enable_interrupts(global);
:=enable_interrupts(INT_RB | H_TO_L);
:=
:=do {
:=} while (TRUE);
:=
:=}
___________________________
This message was ported from CCS's old forum
Original Post ID: 4651 |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: 2 serial ports with interrupts |
Posted: Tue May 28, 2002 4:38 pm |
|
|
Another option is to use one of the Maximum SPI UART's if performance is an issue.
Mark
:=A couple of comments. The H_TO_L define is used for the EXT_INT_EDGE() function and not the enable_interrupts. The following was taken from a device header file:
:=// Constants used in EXT_INT_EDGE() are:
:=#define L_TO_H 0x40
:=#define H_TO_L 0
:=
:=H_TO_L is defined as 0 so there is no adverse effects. Also the H_TO_L and L_TO_H is only for the external ints. It is not used for the PORT B change int.
:=
:=Now to the problem at hand. Are you using an RS232 transceiver chip? The RS232 signals are inverted from the logic signals as well as a different voltage range. Could the int be triggered by the stop bit? Since int_rb doesn't care which way the transition occurs, just the fact that one occured triggers the int. You should probably check for the proper transition and pin before calling the getc() function.
:=
:=Mark
:=
:=:=I've written a simple routine to handle 2 serial ports both working on interrupts. The hardware routine works fine. But the software seem to hang up on the getc command.
:=:=Initially, It recieves a byte correctly but for some reason the RB_INT re-triggers instantly after it leaves the routine. I've tried to to disable the int right after the getc command and even put a delay in case there was a some kind of garbage but nothing seems to work. Any suggestions would be great.
:=:=
:=:=
:=:=
:=:=
:=:=int t;
:=:=
:=:=#use rs232(baud=19200, xmit=PIN_B6, rcv=PIN_B7, PARITY=N, BITS=8)
:=:=#int_rb
:=:=soft_serial_isr()
:=:=
:=:={
:=:= t=getc(); printf("S");
:=:= putc(t);
:=:=}
:=:=
:=:=
:=:=
:=:=#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7, PARITY=N,BITS=8, ERRORS, ENABLE=PIN_C5)
:=:=#int_rda
:=:=hard_serial_isr()
:=:={
:=:= t=getc(); printf("H");
:=:= putc(t);
:=:=}
:=:=
:=:=main()
:=:={
:=:=
:=:=enable_interrupts(global);
:=:=enable_interrupts(INT_RB | H_TO_L);
:=:=
:=:=do {
:=:=} while (TRUE);
:=:=
:=:=}
___________________________
This message was ported from CCS's old forum
Original Post ID: 4652 |
|
![](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
|