help plz ... for use uart

Status
Not open for further replies.

lonely151

New Member
hi every one

i have problem in my code for send data to pc

i try to write it but it dont work !!

can any one help me

this is code
take data from sensors and convert from analog to digital
then send it to PC
but i have problem in uart

 
You'll get a lot more help if you give your variables names more than one letter long.
Code:
unsigned x; //declare the temprature
unsigned char y; //declare the Humdaity
unsigned char z; //declare the Solar radition
unsigned char w;
Are these different?
Code:
uart_init();
initUART()

AND It's incredibly confusing to declare x in main() and then use it as a local variable in all the subroutines. Maybe your compiler can keep them straight, and maybe you can keep track, but I can't.
 
thank mneary i will use variable name
i try to write uart funcation but every time appear problem
i have FYP and i want solve this problem fast plz
 
Sorry, I just get used to people asking questions then vanishing, I shouldn't presume everyone's like that.
 
i was month to write this code
every time happen problem
that is difficult for me becouse i didint study avr as course
 
Since you're still on it, I'll give it a closer look when I get back later.

Which compiler are you using? I'm using WinAVR.

Which AVR are you using? I'm not finding that in your C source code.

While I'm asking silly questions, what is your CPU speed and can you please show your baud rate calculation? Is your clock 10 MHz? (9.83?)
 
Last edited:
OK I found something, chip independent and compiler independent.

Your program initializes your uart twice with two different routines. One of them might be wrong? Choose one, validate it and get rid of the other.
Initialize the uart at the beginning of main() where you initialized the i/o ports.
Your transmission is surrounded by a while(1) control. If it ever started sending characters it would never go back and get new ADC values.
 

thanks

i also use winavr and i use atmega32
and cpu 10 MHz

i want ask her in this part for code
initUART();
while(1){
sendByte(x);
sendByte(y);
sendByte(z);

i use sendbye or printe to send from TX pin ?
and it corecet use while(1) ?
 
I found more.

Your ADC was not working correctly. To align it you must shift right two, not eight.

Code:
result = (result>>2);         // truncate from 10 to
The following lines prevent a clean compile.
Code:
    stdout = stdin = &uart_str; 
                                // map stdin and stdout to serial port
That, along with eliminating

Code:
uart_init();
and cleaning up ambiguous variables leaves me with code that compiles and appears to work.
 
thank u mneary

i try to solve the problem and i end in
this code

but not worken yet
i dont know now what is the problem!!
i use proteus program
when i use any value appear in vitral termnal
but when use anlog to digital not appear !!
can help me plz if u know!!




 
You are still using the 'quote' tags instead of the 'code' tags (go advanced). I will have to copy your code so I can understand it. Maybe in a few days. You can speed this up if you edit your message and change
to
Code:
 in your raw message.



[edit] I get the feeling that I'm working harder on this than you are.
In any case, the best of luck to you.
 
Last edited:
thanks sir
i solve ths problem
and appear the data in vitral termnal
but not the same data !!
u know what is the problem ??
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…