/* atmega2560_pin_change.c Test for pin_change interrupt simulation. */ #include #include #include #include #include "avr_mcu_section.h" /* * This demonstrate how to use the avr_mcu_section.h file * The macro adds a section to the ELF file with useful * information for the simulator */ AVR_MCU(F_CPU, "atmega2560"); static int uart_putchar(char c, FILE *stream) { if (c == '\n') uart_putchar('\r', stream); loop_until_bit_is_set(UCSR3A, UDRE3); UDR3 = c; return 0; } static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); volatile uint8_t interrupts; volatile char buffer[32]; ISR(PCINT0_vect) { buffer[interrupts++] = '0'; } ISR(PCINT1_vect) { buffer[interrupts++] = '1'; } ISR(PCINT2_vect) { buffer[interrupts++] = '2'; } int main() { stdout = &mystdout; PCICR = (1 <