// Copyright 2006 Yamane Akira //ICC-AVR application builder : 2005/04/26 14:11:49 // Target : M8 // Crystal: 4.0000Mhz #include #include #include char buffer[20]; unsigned int i = 22; void port_init(void) { PORTB = 0xFF; DDRB = 0x00; PORTC = 0xFF; DDRC = 0x00; PORTD = 0xFF; DDRD = 0x00; } //UART0 initialize // desired baud rate: 19200 // actual: baud rate:19231 (0.2%) // char size: 8 bit // parity: Disabled void uart0_init(void) { UCSRB = 0x00; //disable while setting baud rate UCSRA = 0x00; UCSRC = BIT(URSEL) | 0x06; UBRRL = 0x0C; //set baud rate lo UBRRH = 0x00; //set baud rate hi UCSRB = 0x18; } //call this routine to initialize all peripherals void init_devices(void) { //stop errant interrupts until set up CLI(); //disable all interrupts port_init(); uart0_init(); MCUCR = 0x00; GICR = 0x00; TIMSK = 0x00; //timer interrupt sources SEI(); //re-enable interrupts //all peripherals are now initialized } // void main(void) { init_devices(); //insert your functional code here... { extern int _textmode; _textmode = 1; init_devices(); sprintf(buffer, "hello world %d", i); puts(buffer); } }