View previous topic :: View next topic |
Author |
Message |
aldinlapinig
Joined: 16 Dec 2005 Posts: 22
|
serial comm problem... |
Posted: Mon Jul 16, 2007 1:13 pm |
|
|
what's wrong?
Code: |
#include <16F628A.h>
#fuses HS, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use rs232(baud=115200, xmit=PIN_B2, rcv=PIN_B1)
#int_rda
void rda_isr(void) {
char temp;
temp = getc(); // Get character from PC
putc(temp); // echo to PC
}
//========================
void main() {
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
while(1);
}
|
I get null for any data I send to the PIC... and interrupt would fire up only once.
Anybody? I've tried using UART but can't get it this time. Even using my old program. I've checked my hardware interface already (it's working). Everything should work fine.
Thanx |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 16, 2007 1:30 pm |
|
|
I tested your program with a 16F628A on a PicDem2-Plus board,
with Hyperterminal Private Edition vs. 6.3, and it worked OK.
I was able to type characters in by hand, and the PIC echo'ed
them back to the terminal window correctly. I used PCM vs. 4.043
for this test. I used a 20 MHz crystal, the same as on your board.
Example of typing:
Quote: | asdfasdfasfdasfd now is the time for |
First just type 'asdf', then type part of a sentence. |
|
|
Guest
|
|
Posted: Mon Jul 16, 2007 4:24 pm |
|
|
Maybe try adding 'ERRORS' option to the use_rs232. It is supposed to reset the uart if an error in reception occurs. This could be caused if your receive pin is not in the idle state (high) between incoming bytes or before the first one that arrives. Without the ERROR option, the continuous receive enable (CREN flag in PIC) must be cycled to clear OERR (overrun error flag in PIC) or FERR (framing error flag in PIC) before reception can resume. |
|
|
|