I2C and usart together on ATMega8


Hi all!
I'd like to use my ATmega8 as interface between USART and i2c (and for some
other things too, but it's not important for my problem). When i write
support for I2C in my code (i'm using Procyon AVRLib) everything is OK, but
when i try to add support for UART, compiler (avr-gcc) says me Error.
Here is my code:
Code:
#include
#include
#include "i2c.c" // i2c library
#include "uart.h" // uart library
// headers
/*
Here is defined some constants like i2c addresses
*
/
void inicializaceI2C() { // setting I2C
i2cInit();
i2cSetLocalDeviceAddr(0xA8, TRUE);
}
void inicializaceUart() { // setting UART
uartInit();
uartSetBaudRate(9600);
}
int main() {
inicializaceI2C();
inicializaceUart();
while(1) { }
return 0;
}
When i try to build it, AVRstudio says me, uart.h is in conflict with
uart2.h (included by i2c.c). When I try compile this code without
Code:
#include "uart.h" // uart library
avr studio says me:
Code:
error: too few arguments in function uartSetBaudRate
When I try modify my code to using UART0, avr studio says me, uart0
nonexists.
Have you any idea how to use i2c and uart together on ATMega8 or should I
use bigger AVR with 2 uarts?
thank you for your reaction
Reply to
Gootes
Loading thread data ...
Hello,
I am not sure this will work for you or not. Remove the "uart.h" in your source file and use the 0 instead of UART0 for the parameter indicating which uart to use. This parameter is needed for uart2.c (which is included as an included file in your source). The uart2.c or uart2.h API supports 2 uarts on the ATmega that has 2 UARTs and therefore the library expects additional parameter for specifying which UART.
Regards, -Pandit
Gootes wrote:
Reply to
ppanbura

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.