Du hast im Datenblatt eine Kleinigkeit übersehen:
2. Within four cycles, write the desired value to IVSEL while writing a
zero to IVCE
Ich würde es so machen:
Code:
uint8_t tmpGICR = GICR;
GICR = tmpGICR | (1 << IVCE);
GICR = tmpGICR | (1 << IVSEL);
Resultierender Code mit -Os ist dann:
Code:
uint8_t tmpGICR = GICR;
38: 8b b7 in r24, 0x3b ; 59
GICR = tmpGICR | (1 << IVCE);
3a: 98 2f mov r25, r24
3c: 91 60 ori r25, 0x01 ; 1
3e: 9b bf out 0x3b, r25 ; 59
GICR = tmpGICR | (1 << IVSEL);
40: 82 60 ori r24, 0x02 ; 2
42: 8b bf out 0x3b, r24 ; 59
Das "four cycle"-Timing wird also eingehalten.
Lesezeichen