Society of Robots - Robot Forum
Software => Software => Topic started by: sakibnaz 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.
-
What happens if you have your initialization like this?
uart1Init();
uartSetBaudRate(1, 9600);
uart0Init();
uartSetBaudRate(0, 9600);
-
Dare I say - you could try WebbotLib and Project Designer from http://webbot.org.uk (http://webbot.org.uk)
-
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.
-
WebbotLib supports the Mega128.
-
Yes you are right. I also think better to use latest Lib Like Webbotavrclib.
I'll try this Lib :)
Thanks.
Regards.
Sakibnaz.