Help: problem with UART of atmega 128

General discussion on Libstock website & codes posted on this website.
Post Reply
Author
Message
boydtvt32
Posts: 7
Joined: 12 Apr 2013 03:13

Help: problem with UART of atmega 128

#1 Post by boydtvt32 » 12 Apr 2013 03:30

hi everybody!
I used Mikro C Pro for code atmega 128,but i can't sent and received data. i used UART Library of Mikro C and Proteus 7.10 to emulation.Please help!

Image

Image
this my exam code:

Code: Select all

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
    }
  }
}



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

Re: Help: problem with UART of atmega 128

#2 Post by filip » 12 Apr 2013 11:58

Hi,

Do you have a real hardware on which you have tried this ?

Regards,
Filip.

boydtvt32
Posts: 7
Joined: 12 Apr 2013 03:13

Re: Help: problem with UART of atmega 128

#3 Post by boydtvt32 » 12 Apr 2013 14:06

i have,but i want try on Proteus first.who used Mikro C to code UART for Atmega 128 can help me,please?

boydtvt32
Posts: 7
Joined: 12 Apr 2013 03:13

Re: Help: problem with UART of atmega 128

#4 Post by boydtvt32 » 13 Apr 2013 08:49

hi,i solved that problem.but have more problem is UART0 of atmega 128 only can sent but can't receive data.who know why???

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

Re: Help: problem with UART of atmega 128

#5 Post by filip » 15 Apr 2013 11:15

Hi,

The UART on ATmega128 functions OK for me on the real hardware.
Are you sure that this line is functioning correctly ?

Regards,
Filip.

boydtvt32
Posts: 7
Joined: 12 Apr 2013 03:13

Re: Help: problem with UART of atmega 128

#6 Post by boydtvt32 » 16 Apr 2013 11:02

filip wrote:Hi,

The UART on ATmega128 functions OK for me on the real hardware.
Are you sure that this line is functioning correctly ?

Regards,
Filip.
oh yeh,thanksyou!
and a question more: you can give for me fuction of uart_reset,uart_on,uart_off ? in Mikro C not have?

boydtvt32
Posts: 7
Joined: 12 Apr 2013 03:13

Re: Help: problem with UART of atmega 128

#7 Post by boydtvt32 » 16 Apr 2013 13:54

how i can sent a string have some character ASCII : /n and /r .ex: TEXT[25]= <CR><LF>OK<CR><LF>.

Post Reply

Return to “Libstock Discussion”