Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 #include <REG51.H> unsigned char ex0_isr_counter = 0; unsigned char eeprom_flag = 0; void ex0_isr (void) interrupt 0 { ex0_isr_counter++; // Increment the count if(ex0_isr_counter == 100) eeprom_flag = 1; } void main (void) { /*----------------------------------------------- Configure INT0 (external interrupt 0) to generate an interrupt on the falling-edge of /INT0 (P3.2). Enable the EX0 interrupt and then enable the global interrupt flag. -----------------------------------------------*/ IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2) EX0 = 1; // Enable EX0 Interrupt EA = 1; // Enable Global Interrupt Flag /*----------------------------------------------- Wait forever. -----------------------------------------------*/ while (1) { if(eeprom_flag == 1) { //Your eeprom write code goes here eeprom_flag = 0; } } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?