go away spammer

Author Topic: AVRLib Dual UART Problem  (Read 2549 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,165
  • Helpful? 111
    • Webbot stuff
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,165
  • Helpful? 111
    • Webbot stuff
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.

 


Get Your Ad Here