Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

is internal osc reliable for uart operation

Status
Not open for further replies.

adnan_merter

Full Member level 3
Joined
Jan 23, 2008
Messages
160
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Location
The most beautiful city of the world
Activity points
2,526
hi,

i am currently trying to make a board using two uart comm. one is pc to board the other is board to board. and i am using 18f2520 and internal osc with pll.

my problem is pc to board connection is fixed baud rate and 9600, never changes. but the other, board to board connection has to be variable baud rate. i mean it initially sends an interrogation word at 300 baud and according to the answer received it has to change the baud up to 19200.

the fixed connection always works correctly but the variable one hangs sometimes not depend on the software or hardware. it works one day and day after it doesn't respond.

is the internal osc reliable for uart operations, this is my only suspect?
 

in general at low baud rates such as 9600 and 19200 I have never had problems with the UART as such - can have problems at speed over 200Kbaud if oscillator does not match the required baud rate

are you polling the UART or using interrupts? does the UART indicate any error conditions such as data overrun

if polling the problem could be the UART is receiving data bytes too fast for the processor to process them (the processor is busy doing other things before polling the UART to see if new data has arrived) - hence you get data overruns - try using interupts with a rinf buffer - you can check for buffer overruns yourself
 

It might be that the new baud rate is not being configured correctly based on the information that you are receiving; this might explain why it is only working sometimes. What does your code look like for configuring the UART baudrate based on the input you're receiving?

Regards,
Willis
 

It might be that the new baud rate is not being configured correctly based on the information that you are receiving; this might explain why it is only working sometimes. What does your code look like for configuring the UART baudrate based on the input you're receiving?

Regards,
Willis

hi,

i am using sotware uart and i defined more than one rs232 connection using same pin, so i can change the speed by changing stream.
like this:

Code:
#use rs232(baud=9600,parity=N,xmit=PIN_A2,rcv=PIN_A3,bits=8, stop=1, stream = PC)
#use rs232(baud=300,parity=E,xmit=PIN_C4,rcv=PIN_C3,bits=7,STOP=1, stream = BOARD_300)
#use rs232(baud=9600,parity=E,xmit=PIN_C4,rcv=PIN_C3,bits=7,STOP=1, stream = BOARD9600)

void com_board()
{
printf("?",BOARD_300);   //for ident of the connected board
get_string(ident,10);
delay_ms(100);
if(ident[0]==A && ident[1]==1)
{
printf("%s",sensor1,BOARD_9600);
get_string9600(sensor1_value,4);   
delay_ms(25);
printf("%s",sensor2,BOARD_9600);
get_string9600(sensor2_value,4);
delay_ms(25);
printf("%s",sensor3,BOARD_9600);
get_string9600(sensor3_value,4);
delay_ms(25);
.
.
.
}
}

i gave the mcu some time to get ready for stream. and started to wait new characters. sometimes it works sometimes it doesn't.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top