|
|
View previous topic :: View next topic |
Author |
Message |
Tagge
Joined: 23 Aug 2005 Posts: 93
|
SW UART, Hyperterminal echoing? |
Posted: Mon Oct 02, 2006 2:32 am |
|
|
I got a strange problem, when sending a string of chars to PIC from Hyperterminal. I get an echo of every char, no Im not having the echo on in HT, I also have to have about >20mS delay between the chars else the chars become rubbish.
Code: | #use rs232(baud=1200, xmit=PIN_B5, rcv=PIN_A4, bits=8, parity=E,RESTART_WDT, ERRORS, invert) |
If i send the chars one by one its no problem or with a delay of >20mS between.
Is this an hardware issue or..
Is there an better, free, terminal program than Hyperterminal, its not known for good stability... |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Oct 02, 2006 3:44 am |
|
|
Quote: | I got a strange problem, when sending a string of chars to PIC from Hyperterminal. I get an echo of every char, no Im not having the echo on in HT, I also have to have about >20mS delay between the chars else the chars become rubbish. | You didn't post a complete program but it sounds like the program in your PIC is echoing the data. I guess you are using a software UART in the PIC? Then this would explain why a small delay in between sending the characters is required, you can't receive data while the PIC is transmitting the echoed character (almost 1ms at 1200 baud).
Quote: | Is there an better, free, terminal program than Hyperterminal, its not known for good stability... | You can try siow.exe which is supplied with your CCS compiler. I often use Terminal from Bray: http://bray.velenje.cx/avr/terminal
(strange, the website is currently unavailable) |
|
|
Tagge
Joined: 23 Aug 2005 Posts: 93
|
|
Posted: Mon Oct 02, 2006 4:46 am |
|
|
Thanks ckielstra, yes, is a software uart. Here is a part that echoes back all chars, but its happening all over the program were sw uart is used, I also uses HW uart and that is working fine.
Code: | char timed_getc()
{
#use rs232(baud=1200, xmit=PIN_B5, rcv=PIN_A4, bits=8, parity=E,RESTART_WDT, ERRORS, invert)
long timeout;
char retval;
timeout=0;
while(!kbhit() && (++timeout< 50000)) // 1/2 sec
delay_us(1);
if(kbhit())
retval = getc();
else
retval = 0;
return(retval);
}
//--------------------------------------------------------
void boot_scrn(void); //proto
void boot_scrn()
{
char string1[BUF_SIZE], password1[BUF_SIZE], in_char;
DISABLE_INTERRUPTS(INT_RDA);//no other communication allowed
DISABLE_INTERRUPTS(INT_TBE);
disp_load();
while(sec5<3){
in_char=timed_getc();
if(in_char=='T'){ //if T from keyboard
DELAY_MS(10);
printf("\r\nPassword?\r\n");
DELAY_MS(10);
strcpy(password1, TEST_IN);
get_string(string1, BUF_SIZE);
if(!strcmp(string1,password1)) //if test mode entered
opto_com(); //poll if testmode wanted
}
}
disp_ver(); //write ver on lcd
prompt_delay();
key=SHOW; //=1
toggle=0;
prompt_delay();
ENABLE_INTERRUPTS(INT_RDA);
ENABLE_INTERRUPTS(INT_TBE);
} |
Any idea? |
|
|
Ttelmah Guest
|
|
Posted: Mon Oct 02, 2006 5:06 am |
|
|
How is the actual connection made?.
The fact that you are using 'invert', suggests that you have some form of simple resistor/diode limiter on the incoming data, rather than a proper transceiver chip. One possibility, is that there is hardware cross-coupling taking place...
The very long delay needed between characters, may also suggest this, with possibly a supply rail being affected.
Best Wishes |
|
|
Tagge
Joined: 23 Aug 2005 Posts: 93
|
|
Posted: Mon Oct 02, 2006 5:39 am |
|
|
Yes, its simple, an IR diod and photo diod. The reciver diod is connected to an comparator op-amp, output from that to the PIC. The IR diod is driven by an transistor BC847 from PIC output. Everything works allright, but the echoing...
It also seems that this echoing is a result of that we speeded up the PIC from 4MHz to 20MHz, does this have something to do with it?
While we used 4MHz it didnt echo back as far as I remember.
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 02, 2006 12:42 pm |
|
|
1. Look for a bad connection, where perhaps someone has shorted
together the Tx and Rx pins.
2. Look for some routine that is called by the program, and it contains
a putc() statement which echoes back the character.
3. Look if a co-worker enabled "local echo" while you were away from
the desk. |
|
|
Tagge
Joined: 23 Aug 2005 Posts: 93
|
|
Posted: Tue Oct 03, 2006 3:27 am |
|
|
Well, the input.c from CCS contains a putc() in get_string(),
I use this for getting strings from the hyperterminal..
Maybe the issue here?
The third alternative aint likely, I work all by myself
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Oct 03, 2006 4:34 am |
|
|
Quote: | Well, the input.c from CCS contains a putc() in get_string(),
I use this for getting strings from the hyperterminal..
Maybe the issue here? | Yes, the function get_string will echo all characters that you type. If you don't want the characters to be echoed then use gets() instead (but then the user can not use the backspace key for correcting the input). |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 03, 2006 1:08 pm |
|
|
Or, just make a local copy of the get_string() function and put it in your
own program. Delete the line that echos the characters. Rename the
function to "my_get_string()". |
|
|
|
|
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
|