View previous topic :: View next topic |
Author |
Message |
RodeKlu
Joined: 31 May 2005 Posts: 2
|
int_rda |
Posted: Tue May 31, 2005 11:31 am |
|
|
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
|
|
Posted: Tue May 31, 2005 1:44 pm |
|
|
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
|
|
Posted: Tue May 31, 2005 2:05 pm |
|
|
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
|
|
Posted: Tue May 31, 2005 11:17 pm |
|
|
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
|
|
|
RodeKlu
Joined: 31 May 2005 Posts: 2
|
|
Posted: Wed Jun 01, 2005 5:54 am |
|
|
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. |
|
|
|