I'm trying to set up the USART module in an XMEGA micro controller and stumble over an error I can not find. For clarity I give you the complete code. So nothing in this header file is missing. (F_CPU
is defined in the main file)
#ifndef USART_H_
#define USART_H_
#include <avr/io.h>
#define USART_BAUDRATE 4800
#define USART_BSCALE -3
#if USART_BSCALE < 0
#define USART_BSEL F_CPU / (pow(2,USART_BSCALE) * 16 * USART_BAUDRATE) - 1
#define USART_BAUD_REAL F_CPU / (pow(2,USART_BSCALE) * 16 * (USART_BSEL + 1))
#else
#define USART_BSEL (1 / (pow(2,USART_BSCALE))) * (F_CPU / (16 * USART_BAUDRATE) - 1)
#define USART_BAUD_REAL F_CPU / (16 * ((pow(2,USART_BSCALE) * USART_BSEL) + 1))
#endif
#define USART_BAUD_ERROR USART_BAUD_REAL * 1000 / USART_BAUDRATE
#if USART_BAUD_ERROR<990 || USART_BAUD_ERROR>1010 /* <-- ERROR IS IN THIS LINE! */
#error Baud rate error too high!
#endif
#endif /* USART_H_ */
The compiler ends with the error
missing binary operator before token "("
in the marked line. There have been brackets before, but I removed them, tried different bracket combinations but the compiler still does see them there. What is wrong here?