I'm writting a bootloader, but I can't interrupt handling on bootloader section.
I would like using external interrupt.
My code is given below:
#define BAUDRATE (F_CPU / 19200 / 16) void interrupt_enable(void) { DDRD &= ~(1 << DDD2); PORTD |= (1 << PORTD2); MCUCR = (1 << IVCE); MCUCR = (1 << IVSEL); EIMSK = (1 << INT0); EICRA = (1 << ISC01); SREG |= 0b10000000; } void uart_initialization(void) { UBRR0H = (BAUDRATE >> 8); UBRR0L = BAUDRATE; UCSR0B |= (1 << TXEN0); } void uart_write_character(char character) { while (!( UCSR0A & (1 << UDRE0))); UDR0 = character; } void uart_write_character_array(char *character_array) { while(*character_array != '\0') { uart_write_character(*character_array); character_array++; } } void main(void) __attribute__ ((naked)) __attribute__ ((section (".init9"))); void main(void) { interrupt_enable(); loop: goto loop; } ISR(INT0_vect) { uart_initalization(); uart_write_character_array("Interrupt has been occoured."); }
My compiler options are given below:
-O1 -c -DF_CPU=16000000 -mmcu=atmega328p -Ttext=0x7000
My linker options are given below:
-O1 -mcall-prologues -DF_CPU=16000000 -mmcu=atmega328p -Ttext=0x7000
I'm using AVR GCC 7.3.0 and GNU AVR Binutils 2.29.1.
What mistake is made by me?
Thanks for replies.