c - Using 8-1 Multiplexer with atmega16 -
i trying use 8-1 multiplexer
@ mega16
trying maximize input pins made program scan addresses of multiplexer
, listen interrupt
if interrupt happens program check address sent @ moment print string on lcd (and managed switch case) ...
the problem is :: when interrupt happens in switch case , execute cases under 1 starts on
ex: if pressed first button(first address) execute cases, if pressed second 1 execute it' case , third case ans on
int main(void) { ////////////////////// setmusk(mcucr,isc01); /* when(isc01 =1 , isc00 =0 )the falling edge of int0 generates interrupt request. can use internal pull resistance*/ clearmusk(mcucr,isc00); /////////////////////// gicr = 0x40; clearmusk(sfior,pud); //enabling pull resistor ddrc = 0xff; lcd_init(); ddrc = 0xff; ddra = 0xff; ddrd = 0x00; lcd_send_command(clear_display_and_ram); lcd_display_string("program starting !!"); _delay_ms(250); _delay_ms(250); _delay_ms(250); _delay_ms(250); _delay_ms(250); _delay_ms(250); _delay_ms(250); lcd_send_command(clear_display_and_ram); sei(); // enabling global interrupt musk while(1) { (porta=0x00;porta <= 7;porta++) ; //todo:: please write application code } } isr(int0_vect)/*sending isr address vector table using statement here (int0_vect)*/ { switch (pina) { case addr0 : { lcd_send_command(clear_display_and_ram); lcd_display_string("first"); _delay_ms(200); lcd_send_command(clear_display_and_ram); break; } case addr1 : { lcd_send_command(clear_display_and_ram); lcd_display_string("second"); _delay_ms(200); lcd_send_command(clear_display_and_ram); break; } case addr2 : { lcd_send_command(clear_display_and_ram); lcd_display_string("third"); _delay_ms(200); lcd_send_command(clear_display_and_ram); break; } case addr3 : { lcd_send_command(clear_display_and_ram); lcd_display_string("fourth"); _delay_ms(250); lcd_send_command(clear_display_and_ram); break; } case addr4 : { lcd_send_command(clear_display_and_ram); lcd_display_string("fifth"); _delay_ms(250); lcd_send_command(clear_display_and_ram); break; } case addr5 : { lcd_send_command(clear_display_and_ram); lcd_display_string("sixth"); _delay_ms(250); lcd_send_command(clear_display_and_ram); break; } case addr6 : { lcd_send_command(clear_display_and_ram); lcd_display_string("seventh"); _delay_ms(250); lcd_send_command(clear_display_and_ram); break; } case addr7 : { lcd_send_command(clear_display_and_ram); lcd_display_string("eights"); _delay_ms(250); lcd_send_command(clear_display_and_ram); break; } //default: //break; } }
mux.h { #define addr0 0x00 //00000000 #define addr1 0x01 //00000001 #define addr2 0x02 //00000010 #define addr3 0x03 //00000011 #define addr4 0x04 //00000100 #define addr5 0x05 //00000101 #define addr6 0x06 //00000110 #define addr7 0x07 //00000111 }
Comments
Post a Comment