Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

ATMEGA2560 Uart code Problem :/

Status
Not open for further replies.

RuneHansen

Junior Member level 1
Joined
Mar 3, 2012
Messages
18
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,293
Location
Denmark, Sjælland, Kalundborg
Activity points
1,398
hey all.

i have a problem with a Uart code i have made in MikroC. i have tryed many things, but cant make it work :I

i want to send a text command via the Uart and then the Chip lights up some certain leds, but i cant light 2 leds up at once and turn them off as i want to because the loop just keep following its path and i dont know what im doing worng?

ps: im from Denmark- it explains my grammar and spelling :D

Here is the code :)



Code:
void main() {

UART1_Init(9600); // konfiguration af UART modulet til 9600 bps.
Delay_ms(100); // Vendt på UART modulet til at blive stabilt.

UART1_Write_Text("ATMEGA2560 RESET"); // Under reset = send DATA.

UART1_Write(13);UART1_Write(10);

DDL7_bit = 1; // Sæt PORTL7 til at være digitale Udgange.
DDL6_bit = 1; // Sæt PORTL6 til at være digitale Udgange.


do {



if (UART1_Data_Ready() == 0) { // Hvis data er modtaget...
UART1_Read_Text("PL7 = ON", "PORTL_PL7_ON", 255); // Læs den modtaget data indtil "--" er fundet...
UART1_Write_Text("PL7 = ON"); // Send (DATA) tilbage.

PORTL = 0x80;

}



if (UART1_Data_Ready() == 0) { // Hvis data er modtaget...
UART1_Read_Text("PL7 = OFF", "PORTL_PL7_OFF", 255); // Læs den modtaget data indtil "--" er fundet...
UART1_Write_Text("PL7 = OFF"); // Send (DATA) tilbage.

PORTL = 0x00;

}



if (UART1_Data_Ready() == 0) { // Hvis data er modtaget...
UART1_Read_Text("PL6 = ON", "PORTL_PL6_ON", 255); // Læs den modtaget data indtil "--" er fundet...
UART1_Write_Text("PL6 = ON"); // Send (DATA) tilbage.

PORTL = 0x40;

}



if (UART1_Data_Ready() == 0) { // Hvis data er modtaget...
UART1_Read_Text("PL6 = OFF", "PORTL_PL6_OFF", 255); // Læs den modtaget data indtil "--" er fundet...
UART1_Write_Text("PL6 = OFF"); // Send (DATA) tilbage.

PORTL = 0x00;

}




}while(1);
}
can some of you help me?? :)
Thanks!

And it is also my first post on this forum :) so.. yes.. im a newbit :D
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top