Serial Communication Atm8
Serial Communication Atm8
#include <avr/io.h>
//Header file for AVR device specific I/O Definitions.
#include <avr/interrupt.h>
//Header file for incorportaing interrupt handling faclity (not used here).
#include <util/delay.h>
//Header file for incorporating delay routines.
#include <avr/pgmspace.h>
//Header file for incorporating Program space string utilities.
#include <stdlib.h>
//ISO Standard library of C functions and macros.
#include "USART.h"
//Defines C functions for accessing USART Module.
#define BIT(x)
(1 << (x)) //Set a particular bit mask
#define CHECKBIT(x,b) (x&b)
//Checks bit status
#define SETBIT(x,b) x|=b;
//Sets the particular bit
#define CLEARBIT(x,b) x&=~b;
//Sets the particular bit
#define TOGGLEBIT(x,b) x^=b;
//Toggles the particular bit
void WaitMs(unsigned int ms);
void welcome_screen(void);
int main()
{
unsigned int ch;
uart_init(9600);
return 0;
}
void setup()
{
DDRB |= (1<<1) | (1<<2) | (1<<3) | (1<<5) ; // BLANK, SS, MOSI, SCLK as OUTPUTS
DDRD |= (1<<3) | (1<<4) | (1<<6) | (1<<7) ; // VPRG, XLAT, GSCLK, Debug as OUTPUTS
DDRC = 255;
XLAT_Low;
BLANK_High;
VPRG_Low;
Debug_Low;
//Timer 1 (16bit)
TCCR1A = (1<<WGM11) | (0<<WGM10);
= Gray_Scale_Depth;
//Timer 0 (8bit)
TCCR0A = (1<<WGM01) | (0<<WGM00);
// CTC
// f(OCR) = F_CPU/2/Prescaler
//UART Initialisation
UCSR0A |= (1<<U2X0);
// Double up UART
// Asynchrous 8N1
UBRR0H = 0;
UBRR0L = 1; //Baud Rate 1 MBit --> 0% Error at 16MHz
//Enable global interrupts
sei();
//Configure SPI
SPCR = (1<<SPE)|(1<<MSTR);
SPSR = B00000000;
ptr=display_buffer;
}