/* these two lines take care of the IO definitions for the device, and the interrupts available for them */ #include #include /* put comments in here for future reference, showing what the device is intended to do, which device is to be used, and the fuse settings (and why) */ /* This is a template created by cutting bits from a stepper motor drive Some port direction commands are included as examples */ /* Intended for ATmega168P */ /* Clock rate is 1.0 MHz (8MHz internal oscillator (default), divide by 8 (default), to give CLKIO of 1MHz */ // Fuse high byte is default (0xDF) See data sheet page 297 /* Fuse low byte is 0x22: ((NB fuses active low) See data sheet page 298 * CLKDIV8 0 (div8 active) * CLKOUT 0 (clk out active) * SUT1 1 (fast rising power) * SUT0 0 * CKSEL3 0 8MHz internal osc * CKSEL2 0 * CKSEL1 1 * CKSEL0 0 */ /* Interrupt vectors */ // If we were using interrupts the interrupt vectors would be here // there is a useful list at http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html /* Port direction setting */ inline void port_direction_init() { /* No PORTA or PORTE on the ATMEGA168P DDR is Data Direction Register PORT is used when referring to outputs PIN is used when referring to inputs See ATMEGA168P datasheet section 13 */ // Assign all ports as inputs. DDRB = 0 ; DDRC = 0 ; DDRD = 0 ; // define outputs DDRB |= 0 ; // TODO. Put a 1 in each position which needs to be an output // Set high outputs // set low outputs PORTB = 0 ; } int main(void) { // IO port initialisation port_direction_init(); while (1) { // TODO put code in here } }