// Copyright 2006 Yamane Akira // m48bitInOut // Target : M48 // Crystal: 4.0000Mhz // Exaple Program for Bit SET Clear // Also Include Read Modify Operation // Programmed by A.Yamane #include #include void port_init(void) { PORTB = 0xFF; DDRB = 0x00; PORTC = 0x7F; //m103 output only DDRC = 0x07; PORTD = 0xFF; DDRD = 0x00; } //call this routine to initialize all peripherals void init_devices(void) { //stop errant interrupts until set up CLI(); //disable all interrupts port_init(); MCUCR = 0x00; EICRA = 0x00; //extended ext ints EIMSK = 0x00; TIMSK0 = 0x00; //timer 0 interrupt sources TIMSK1 = 0x00; //timer 1 interrupt sources TIMSK2 = 0x00; //timer 2 interrupt sources PCMSK0 = 0x00; //pin change mask 0 PCMSK1 = 0x00; //pin change mask 1 PCMSK2 = 0x00; //pin change mask 2 PCICR = 0x00; //pin change enable PRR = 0x00; //power controller SEI(); //re-enable interrupts //all peripherals are now initialized } void Write_Perip(unsigned char WDATA) { PORTB = WDATA; DDRB = 0xFF; PORTC &= ~0x04; PORTC &= ~0x02; PORTC |= 0x06; DDRB = 0x00; } unsigned char Read_Perip(void) { unsigned char RDATA; DDRB = 0x00; PORTC &= ~0x04; PORTC &= ~0x01; RDATA = PINB; PORTC |= 0x05; DDRB = 0x00; return RDATA; } // void main(void) { init_devices(); //insert your functional code here... while(1) { //actual program start here } }