LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-10-2013, 01:28 PM   #1
akhilmohan
LQ Newbie
 
Registered: Sep 2013
Posts: 1

Rep: Reputation: Disabled
UART displays random character


Hello,
What am loading to the TXREG is 'u' (0x75) but what it displays on the C Kermit is 'Q' (0x51), and am not sure how to fix this ?
Sample code is,
Code:
Code:
#include<xc.h>
#define _XTAL_FREQ 20000000
//#define Baud_Rate 19200
__CONFIG (1, OSC_HS);
__CONFIG (2, WDTDIS & PWRTEN & BORDIS & LVPDIS);

void main()
{
// Initialization set up of UART Transmission
    TRISCbits.RC6 = 0;
    TRISCbits.RC7 = 1;
    SPBRG = 64;
    TXSTAbits.BRGH = 1;
    TXSTAbits.SYNC = 0;
    RCSTAbits.SPEN = 1;
    TXSTAbits.TXEN = 1;
    while(1)
    {
        TXREG = 'u';
        while(TXIF==0);
    }
}
 
Old 09-17-2013, 01:26 AM   #2
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
Very little information, so i will consult my crystal ball. I assume this is for some embedded board.
In most cases when serial data is wrong it is mostly bad timing. Normally there should be a formula to calculate the clock register value from the given xtal value and the wanted baudrate. Can you show us this calculation.

Also give us some more info about the hardware you are using.

Cheers
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where does uart console get its value of uart port membase? unifoxz Linux - Kernel 1 12-20-2011 02:28 PM
Ubantu LTS on Upgrade displays "Square box" for each character pramod123 Ubuntu 0 08-18-2009 05:32 AM
What command displays the character map? lyrica45 Linux - Newbie 1 02-25-2009 02:09 AM
monitor displays random pixels on Xwindows exit riemann_noodles Slackware 1 08-01-2005 02:53 PM
Produce random character with c program liguorir Linux - Software 4 05-23-2004 06:30 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration