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

USART baud rate error

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



Joined: 02 May 2011
Posts: 1

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

USART baud rate error
PostPosted: Mon May 02, 2011 1:18 pm     Reply with quote

hi
I am using PIC18F2525 USART to send a character and string via Rs232 to Hyperterminal....I am using a 4MHz crystal oscillator, i am able to display the characters on the screen only at 250000 baud rate with every character repeating itself

meaning
my Output needs to be
D
dimple
bhuta

my current output is
DDddiimmppllee
bbhhuuttaa

I have included my code, any advice would be very appreciated
Thank you
Code:

#include <p18f2525.h>
#include <usart.h>
 #include <string.h>

#pragma config OSC= XT
#pragma config WDT = OFF
#pragma config MCLRE = ON
#pragma config LVP = OFF
#pragma config BOREN = ON

void USART_setup (void)
{
TXSTAbits.SYNC =0;
SPBRG = 0x00;
TXSTAbits.BRGH =1;
RCSTAbits.SPEN =1;
PIE1bits.TXIE =0;
TXSTAbits.TX9 =0;
TXSTAbits.TXEN =1;
}

void putc(unsigned char ch)
{
while (PIR1bits.TXIF != 0)
TXREG =ch ;
}

void puts(far rom char *Str )
{
do
 {
 unsigned char c;
 c = *Str;
 putc (c);
if (*Str==13) putc (10);
if (*Str == 10) putc(13);
Str++;
 } while ((*Str) != 0 );
}
void main (void)
{
TRISC =0b10000000;
USART_setup ();
while(1)
{
putc('D');
puts ("dimple\n");
puts("bhutadc\n");
}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 02, 2011 1:26 pm     Reply with quote

You're using the Microchip C18 compiler, but you're posting on the CCS
compiler forum. They're not compatible. Here is the C18 forum:
http://www.microchip.com/forums/f3.aspx
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