View previous topic :: View next topic |
Author |
Message |
joelinacio Guest
|
rs232 with 2 stopbit |
Posted: Thu Sep 16, 2004 10:23 pm |
|
|
It`s possible the use of "#use rs232 " with 2 stopbits? I have used the vfd display of futaba and it only work with 9600bps and 2 stops... |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Fri Sep 17, 2004 12:19 am |
|
|
You can set the UART to 9-bit transmission mode and make the ninth bit look like a stop bit. |
|
|
joelinacio
Joined: 16 Sep 2004 Posts: 9 Location: Brasil
|
Re: rs232 with 2 stopbit |
Posted: Fri Sep 17, 2004 8:05 am |
|
|
# use rs232 (baud=9600, xmit=PIN_B2, rcv=PIN_B1,bits=9)
I did this...but don't work... |
|
|
Ttelmah Guest
|
Re: rs232 with 2 stopbit |
Posted: Fri Sep 17, 2004 9:26 am |
|
|
joelinacio wrote: | # use rs232 (baud=9600, xmit=PIN_B2, rcv=PIN_B1,bits=9)
I did this...but don't work... |
What o you mean "it doesn't work"?. The ninth data bit in this case is taken from the RS232_ERRORS variable. You need to set this to a high level to give the extra 'stop'.
Hence, something like:
#bit bit_nine = RS232_ERRORS.7
bit_nine=1;
putc('A');
Should send the letter 'A', with two stop bits.
Best Wishes |
|
|
joelinacio
Joined: 16 Sep 2004 Posts: 9 Location: Brasil
|
Re: rs232 with 2 stopbit |
Posted: Fri Sep 17, 2004 12:41 pm |
|
|
Is possible the use of printf()? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Sep 17, 2004 12:56 pm |
|
|
Yes, anything going out the UART will have the nineth bit set if you following the suggestions. |
|
|
joelinacio
Joined: 16 Sep 2004 Posts: 9 Location: Brasil
|
|
Posted: Fri Sep 17, 2004 5:03 pm |
|
|
Quote: |
I used this code to test...the display show ''12:#@&4*"
the correct is "12:45:50"...
|
Code: |
# include <16f873.h>
# use delay (clock=4000000)
# fuses XT,NOWDT,NOPROTECT,NOLVP,NODEBUG,NOWRT,NOCPD
# use rs232 (baud=9600, xmit=PIN_B2, rcv=PIN_B1, bits=9)
# bit bit_nine = RS232_ERRORS.7
int hora,minuto,segundo,controle;
void main()
{
bit_nine=1;
hora=12;
minuto=45;
segundo=50;
controle=11; //volta o cursor para o inicio
while(1)
{
printf("%c%02u:%02u:%02u",controle,hora,minuto,segundo);
delay_ms(1000);
segundo++;
if(segundo==60)
{
segundo=0;
minuto++;
}
if(minuto==60)
{
minuto=0;
hora++;
}
if(hora==24)
{
hora=0;
}
}
}
|
|
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sat Sep 18, 2004 6:46 am |
|
|
As a test try adding a 10ms delay between characters, ie. print to a string and then print the string one character at a time with a delay between characters.
Also is there any chance the buffer on the RS232 receiving UART is being overrun? Try a different device (different PC) to receive the RS232.
I hope you realize that your delay_ms(1000) is not going to give you exact seconds because of the time the rest of the code takes to execute. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
joelinacio
Joined: 16 Sep 2004 Posts: 9 Location: Brasil
|
|
Posted: Mon Sep 20, 2004 7:27 pm |
|
|
The pic is not send the nine bit...I got the signal with a digital
oscilloscope...
the code for nine bit is correct?[/img] |
|
|
joelinacio
Joined: 16 Sep 2004 Posts: 9 Location: Brasil
|
|
Posted: Thu Sep 30, 2004 10:21 am |
|
|
UFAAA!!!! Finaly....
Code: |
# include <16f873.h>
# use delay (clock=4000000)
# fuses XT,NOWDT,NOPROTECT,PUT//,NODEBUG,NOWRT,NOCPD,NOBROWNOUT,NOWRT,NOLVP
# use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7, bits=9) // use serial hardware
# bit bit_nine = 0x98.0
int hora,minuto,segundo,controle;
long int tempo;
void main()
{
#asm
bsf 0x03,5 ; bank 1
bsf 0x98,0 ; set bit 0 txsta reg...nine bit data
bcf 0x03,5 ; bank 0
#endasm
hora=12;
minuto=45;
segundo=50;
controle=11; //volta o cursor para o inicio
tempo=10;
while(1)
{
printf("%c%02u:%02u:%02u",controle,hora,minuto,segundo);
delay_ms(1000);
segundo++;
if(segundo==60)
{
segundo=0;
minuto++;
}
if(minuto==60)
{
minuto=0;
hora++;
}
if(hora==24)
{
hora=0;
}
}
}
|
|
|
|
|