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

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
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…