// Copyright 2006 Yamane Akira // Test Soft-Uart : See Atmel Applicaton Note 305 // File: soft_testm8.c // Target : m8 // Crystal: 4.0 Mhz // Date 07/12/05 // Written/adapted by Dipl.Ing.J.Zastrow // for Imagecraft ICCAVR Ver. 6.28c // Modified by A.Yamane // Usage : if you need more then one UART // Tested with STK500 (Atmel) // Customer settings : SEE soft_uartm8.s #include #include //function prototypes for soft_uart.s //one byte return value in R16 !!! extern unsigned char getit(void); //one byte argument in R16 extern putit(register unsigned char key); //initialise TxD,RxD port pins extern void init_soft_uart(void); void port_init(void) { //default settings all inputs and pull up PORTB = 0x00; DDRB = 0xFF; PORTC = 0xFF; DDRC = 0x00; PORTD = 0xFF; DDRD = 0x00; } //call this routine to initialise all peripherals void init_devices(void) { //stop errant interrupts until set up CLI(); //disable all interrupts port_init(); MCUCR = 0x00; GICR = 0x00; TIMSK = 0x00; SEI(); //re-enable interrupts //all peripherals are now initialised } //Simply connect RS232 SPARE to //PC2 to receive and PC3 to transmitt void main(void) { unsigned char s; //default init_devices(); //do custom settings in soft_uart.s !!! init_soft_uart(); while(1){ putit('T'); //T putit('E'); //E putit('S'); //S putit('T'); //T putit(':'); //: s = getit(); putit(s); putit(0x0D);//CR putit(0x0A);//LF }//end while }//end main