Here is a code that doesn't work for me for reasons that I ignore until now
The code for the atmega8
[code]
/*
* main.c
*
* Created: 25/05/2012 18:31:36
* Author: MASNSN
*/
#include
#include
#include
#include "lcd.h"
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
char *message;
ISR(USART_RXC_vect){
if (*message !='')
{
*message = UDR;
message++;
}
}
//Initialize the usart
void USART_Init(void);
int main()
{
//Initialize the LCD
LCDInit(LS_NONE);
//Clear previous message
LCDClear();
//Inittialize the usart
USART_Init();
//enable global interrupts
sei();
//Display the message within the lcd
LCDWriteString(*message);
return 0;
}
void USART_Init()
{
// set baudrate
UBRRL=BAUD_PRESCALE; //low byte
UBRRH=(BAUD_PRESCALE>>8); //high byte
//default data frame format: asynchronous mode,no parity, 1 stop bit, 8 bit size
//Set the frame size to 8 bits
UCSRC = (1
The code for the atmega8
[code]
/*
* main.c
*
* Created: 25/05/2012 18:31:36
* Author: MASNSN
*/
#include
#include
#include
#include "lcd.h"
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
char *message;
ISR(USART_RXC_vect){
if (*message !='')
{
*message = UDR;
message++;
}
}
//Initialize the usart
void USART_Init(void);
int main()
{
//Initialize the LCD
LCDInit(LS_NONE);
//Clear previous message
LCDClear();
//Inittialize the usart
USART_Init();
//enable global interrupts
sei();
//Display the message within the lcd
LCDWriteString(*message);
return 0;
}
void USART_Init()
{
// set baudrate
UBRRL=BAUD_PRESCALE; //low byte
UBRRH=(BAUD_PRESCALE>>8); //high byte
//default data frame format: asynchronous mode,no parity, 1 stop bit, 8 bit size
//Set the frame size to 8 bits
UCSRC = (1