CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

rs232 with 2 stopbit

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
joelinacio
Guest







rs232 with 2 stopbit
PostPosted: Thu Sep 16, 2004 10:23 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 17, 2004 12:19 am     Reply with quote

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

View user's profile Send private message Send e-mail MSN Messenger

Re: rs232 with 2 stopbit
PostPosted: Fri Sep 17, 2004 8:05 am     Reply with quote

# 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
PostPosted: Fri Sep 17, 2004 9:26 am     Reply with quote

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

View user's profile Send private message Send e-mail MSN Messenger

Re: rs232 with 2 stopbit
PostPosted: Fri Sep 17, 2004 12:41 pm     Reply with quote

Is possible the use of printf()?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 17, 2004 12:56 pm     Reply with quote

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

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Fri Sep 17, 2004 5:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Sep 18, 2004 6:46 am     Reply with quote

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

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Mon Sep 20, 2004 7:27 pm     Reply with quote

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

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu Sep 30, 2004 10:21 am     Reply with quote

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;
               }
         }

    }
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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