Author Topic: AVRLib Dual UART Problem  (Read 1183 times)

0 Members and 1 Guest are viewing this topic.

Offline sakibnazTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
AVRLib Dual UART Problem
« on: April 15, 2011, 03:41:41 PM »
Hello.

I am trying to enable Dual UART with ATMega128 MCU using uart2.h from Procyon AVRlib.
I have added all the necessary .c and .h files from AVRLib into my AVR Studio Project. The project is compiling error free but dual UART (UART0 and UART1 together) is not working, only Single UART (UART0) is working fine. My main function is below presented:

#include <avr/io.h>
#include <avr/interrupt.h>
#include "global.h"
#include "uart2.h"
#include "rprintf.h"

int main(void)
{
    uart0Init();
    uartSetBaudRate(0, 9600); 
    uart1Init();
    uartSetBaudRate(1, 9600);
    rprintfInit(uart0SendByte);
    rprintf("Hello UART0\r\n");
    rprintfInit(uart1SendByte);
    rprintf("Hello UART1\r\n");

    return 0;
}


Here this code is compiling properly without error but UART0 and UART1 not working together. But if I comment the lines of UART1 and rebuild the project then UART0 is working  >:(

Any suggestion please.

Thanks in advance.

Regards.
Sakibnaz.

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: AVRLib Dual UART Problem
« Reply #1 on: April 17, 2011, 06:41:02 PM »
What happens if you have your initialization like this?
Code: [Select]

    uart1Init();
    uartSetBaudRate(1, 9600);
    uart0Init();
    uartSetBaudRate(0, 9600); 
Imperial College Robotics Society
www.icrobotics.co.uk

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,072
  • Helpful? 107
Re: AVRLib Dual UART Problem
« Reply #2 on: April 17, 2011, 06:52:03 PM »
Dare I say - you could try WebbotLib and Project Designer from http://webbot.org.uk
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline sakibnazTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: AVRLib Dual UART Problem
« Reply #3 on: April 17, 2011, 06:59:16 PM »
Hello.

Thanks for your reply. Yes I saw WebbotLib. Its nice. But my target MCU is Mega128, that's why I am trying to use the UART lib from AVRLib, as that's make is for Mega128.

I have tested but if I try to Init both UART0 and UART1 then nothing happens, but code is building without error. I have attached my AVR Studio Project with Proteus 7.1 VSM for your review.

Here the codes for UART1 is commented and UART0 is working. Please un-comment the UART1 lines, then no UART's will work :(

Any suggestion what I am missing?

Regards.
Sakibnaz.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,072
  • Helpful? 107
Re: AVRLib Dual UART Problem
« Reply #4 on: April 17, 2011, 07:08:23 PM »
WebbotLib supports the Mega128.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline sakibnazTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: AVRLib Dual UART Problem
« Reply #5 on: April 17, 2011, 07:16:19 PM »
Yes you are right. I also think better to use latest Lib Like Webbotavrclib.
I'll try this Lib :)

Thanks.

Regards.
Sakibnaz.

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
4118 Views
Last post December 06, 2007, 11:06:21 AM
by Admin
5 Replies
3972 Views
Last post April 25, 2008, 07:21:34 AM
by Admin
11 Replies
3647 Views
Last post October 02, 2008, 10:36:09 AM
by superchiku
12 Replies
2387 Views
Last post July 24, 2009, 09:59:04 PM
by Admin


Get Your Ad Here