Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Uart problem using internal oscilator pc to pic18f4550

Status
Not open for further replies.

maqs

New Member
I M USING INTERNAL OSCILATOR TO SEND DATA FROM PIC 18F4550 TO HYPERTERMINAL .BUT GETTING GARBAGE VALUE.
I CAME TO KNOW THE BAUDRATE PROBLEM.
I CHECKED IT MANY TIMES BUT DIDN,T FIND SOLUTION.
I M DOING IN THIS WAY

#include<p18f4550.h>

#pragma CONFIG WDT = OFF ; Disable watchdog timer
#pragma CONFIG DEBUG = ON ; Enable Debug Mode
#pragma CONFIG LVP = OFF ; Low-Voltage programming disabled (necessary for debugging)
#pragma CONFIG FOSC = INTOSC:USB-HS ; Internal oscillator, port function on RA6

void main (void)
{
TRISCbits.TRISC6=0;
///////////////////////////////////// USING INTERNAL OSCILATOR ///////////////
OSCCON=0x72; // 8MHZ
//////////////////////////// setting baud rate ////////////////////////////////////////
//CONFIG1H=0xC;
//CONFIG1L=0x4;
SPBRG =51; // BAUDRATE SET TO 2400
BAUDCONbits.BRG16=0;
////////////////////////// setting transmit control register ///////////////////////////
TXSTAbits.SYNC= 0; // ASYNCHRONOUS MODE
TXSTAbits.TX9 =0;
TXSTAbits.TXEN= 1;
TXSTAbits.BRGH=0;
/////////////////////////// SETTING RECIEVE control register ///////////////////////////
RCSTAbits.SPEN=1;
RCSTAbits.CREN=1;
TXREG='B';
while(PIR1bits.TXIF==0);
}

PLZZZ HELP ME ............................
 
code :


#include<p18f4550.h>
#pragma config FOSC=HS, FCMEN=ON, WDT=OFF, IESO=OFF, XINST=OFF, LVP=OFF
void main (void)
{

TRISCbits.TRISC6=0;

//////////////////////////// setting baud rate ////////////////////////////////////////

SPBRG =129; // BAUDRATE SET TO 2400

BAUDCONbits.BRG16=0;

/////////////////////////// SETTING RECIEVE control register ///////////////////////////
RCSTAbits.SPEN=1;
RCSTAbits.CREN=1;


////////////////////////// setting transmit control register ///////////////////////////
TXSTAbits.SYNC= 0; // ASYNCHRONOUS MODE
TXSTAbits.TX9 =0;
TXSTAbits.TXEN= 1;
TXSTAbits.BRGH=0;


//////////////////////////// SENDING DATA TO TRANSMIT BUFFER REGISTER ///////////////////


while(1)
{
TXREG='10101010';
while(PIR1bits.TXIF==0);
}

}


output find on hyper terminal is

11111111
11111111
11111111
11111111
11111110
11111110
11111110
11111110
11111110
11111100
11111100
11111100
11111100
11111100
11111000
11111000
11111000
11111000
11111000
11111000
11111000
11111000
11111000
11110000
11110000
11110000
11110000
11110000
11110000
11110000
11110000
11100000
11100000
11100000
11100000
11100000
11100000
11100000
11100000
11100000
11100000
11000000
11000000
11000000
11000000
11000000
11000000
11000000
11000000
11000000
11000000
11000000
11000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
10000000
00000000
00000000
00000000
00000000
and so on .gettting oooooooo
 
Cool!

Well 1 means a low voltage at the PC RX pin. So it looks like the voltage at the PC is charging like a cap, with the voltage ramping over each byte sent. You can see it rises fast at first then slower as the bytes progress. Until finally it is a fixed HI level to the PC.

I bet you have wired the MAX232 wrong and have one of its 10uF caps connected to the output pin that goes to the PC. Or maybe to the PIC's TX pin.
 
i m now using PICDEMFSUSB DEMO BOARD .ON WHICH IT GIVE NO OUTPUT ON HYPER TERMINAL.

CONSTANT 1VOLTS APPEAR ON THE TRANSMIT PIN OF CONTROLLER AS ON OTHER PINS..

I HAV DOUBT IN DEFINING CONFIGRATION FILE FOR CLOCK AND OTHER TIMER DEF. ETC

GUIDE ME .............
 
If you are getting 1 volt on an output pin, it would seem that something is shorting out on the board, and the voltage regulator is current limiting the system to 1 volt. Check your wiring, and try to detect if any part of the board is getting hot.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top