problem in uart communication!!!

General discussion on mikroC PRO for AVR.
Author
Message
n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

problem in uart communication!!!

#1 Post by n_vikranth » 14 Feb 2012 06:14

I followed UART library and done every thing as mentioned in library file including connections...
i using ATMEGA16A and 8Mhz crystal, but i cant communicate with pc....
wat ever i entered in the screen and transmitted it should be back,but the reply is always something like EEEEEEEEEEE....... what is my mistake?
how to communicate with pc using uart(rx and tx).

and when ever i build a program it shows Generated baud rate is 9615 bps (error = 0.16 percent)

how to generate accurate 9600 bps , help me........

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: problem in uart communication!!!

#2 Post by filip » 14 Feb 2012 10:47

Hi,

How did you connect the ATmega16A ?
Do you have some custom board ?
Did you enter the proper oscillator value and set the appropriate baud rate in the Terminal window that you use ?

Regards,
Filip.

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#3 Post by n_vikranth » 15 Feb 2012 15:08

Hi, i followed inbuild library file instructions(for program and circuit)...

and also i tried communication between atmega16a to atmega16a with 4Mhz crystal,its working good..

but when i try to communicate with pc it shows error, so i change to 8Mhz crystal as mentioned in library file,anyway it showing the same error as EEEEEEE for all the data send by ATMEGA16A...
and iam not using any board, i simply followed the circuit gave in library file....

Generated baud rate is 9615 bps (error = 0.16 percent) is the error showing always....

i planned to communicate with gsm mobule sim300 and also to gps,because of the baud rate problem i cant communicate, help me to generate accurate baudrate...

first try to solve my problem with basic communication with pc,then i wil try with other modules...

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#4 Post by n_vikranth » 15 Feb 2012 15:21

i set crystal value in project setting tab and 9600 baud rate is set by using the program as mentioned below


char uart_rd;

void main() {

UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
UART1_Write_Text("Init");
UART1_Write(13);UART1_Write(10);
while (1) { // Endless loop
if (UART1_Data_Ready()) { // If data is received,
uart_rd = UART1_Read(); // read the received data,
UART1_Write(uart_rd); // and send data via UART
}
}
}

in last message u mentioned something like terminal window, wat is that i cant undersand,can u tell clearly pls...


but i just build program mentioned in library file,without adding anything...

is there anything to add other than above mentioned program...

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#5 Post by n_vikranth » 16 Feb 2012 10:13

Mr.Filip try to solve my problem,

Pls tell me, how to generate accurate 9600 bps using 4MHZ crystal with mikroc pro compiler

TA2TF
Posts: 21
Joined: 14 Mar 2006 21:00
Location: ISTANBUL

Re: problem in uart communication!!!

#6 Post by TA2TF » 16 Feb 2012 10:57

it may be your project settings in compiler... is it 4 MHz ?

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#7 Post by n_vikranth » 16 Feb 2012 17:31

Ya I kept 4Mhz in then y I can't communicate

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: problem in uart communication!!!

#8 Post by filip » 17 Feb 2012 13:11

Hi,

You said that :
and also i tried communication between atmega16a to atmega16a with 4Mhz crystal,its working good..

but when i try to communicate with pc it shows error, so i change to 8Mhz crystal as mentioned in library file,anyway it showing the same error as EEEEEEE for all the data send by ATMEGA16A...
and iam not using any board, i simply followed the circuit gave in library file....
How did you connect it to the PC ?
Which hardware did you use ?
Did you use any UART terminal and did you set it properly ?

Regards,
Filip.

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#9 Post by n_vikranth » 17 Feb 2012 17:52

i followed the below circuit with 4Mhz crystal and i used in built USART terminal in mikroc pro...
settings r 9600 bps, 1stop bit, 8 databits,no parity,buffer size 1024,flow control-none...
Attachments
serial.JPG
serial.JPG (50.3 KiB) Viewed 7492 times
Last edited by n_vikranth on 19 Feb 2012 11:19, edited 1 time in total.

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#10 Post by n_vikranth » 17 Feb 2012 17:54

Generated baud rate is 9615 bps (error = 0.16 percent) is the error showing always....

this can be a problem r not....

How to generate accurate baudrate?????


This is my error reply from pc=€€øøøøøø€øøø€ø€øø€€øø€€øø€€øø€€øø€€€ø€€ø€€ø€€ø€€ø€€ø€€ø€

for all data send from ATMEGA16A......

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#11 Post by n_vikranth » 19 Feb 2012 10:43

I used 4Mhz crystal as shown in below picture, wat are the setting to be changed in project window shown below, I think setting may be problem.... atleast help me to set the correct settings, because of uart communication i feel bad on Mikroelectronika....

other than uart, mikroc pro working very good... so solve my little problem,soon...

My all current projects are delayed because of uart communication,so answer me...

r else, FILIP tell me at wat time u wil be in online... then i can easily discuss with u, about my doubts....
Attachments
crystal.JPG
crystal.JPG (2.37 KiB) Viewed 7493 times
settings.JPG
settings.JPG (48.04 KiB) Viewed 7493 times

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#12 Post by n_vikranth » 19 Feb 2012 11:21

Mr.FILIP I gav all details about my ciruit, then y u r waiting for reply....
Help me,pls.....

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: problem in uart communication!!!

#13 Post by filip » 20 Feb 2012 13:32

Hi,

Please, can you attach here your project ?

Regards,
Filip.

n_vikranth
Posts: 35
Joined: 11 Jan 2012 15:06

Re: problem in uart communication!!!

#14 Post by n_vikranth » 21 Feb 2012 14:08

project file attached,pls fuse this simple program in ATMEGA16A and use 4Mhz crystal as a oscillator(with 22pf) as shown in above circuit and solve the problem & reply me the solution soon...
Attachments
UART.rar
(32.21 KiB) Downloaded 257 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: problem in uart communication!!!

#15 Post by filip » 22 Feb 2012 10:01

Hi,

Please, see in the following schematic (page 4) how we have utilized the oscillator circuit (it applies to all of our boards that can handle ATmega16) :
http://www.mikroe.com/eng/downloads/get ... l_v100.pdf

Try it and inform me of the results.

Regards,
Filip.

Post Reply

Return to “mikroC PRO for AVR General”