Hi,
I've been using a 3216 board graciously provided by Spence Konde along with his core and UPDI programmer tutorial. So far so good. I'm able to load up some sketches using the Arduino IDE, and then I'm able to get a pin change type interrupt to work by setting registers appropriately. Very satisfied with all of that. When I try to get a timer compare interrupt to kick off I get a suggestion that I'm misspelling the ISR name. Most of what I made below comes from the app notes linked here. I'll put the code that works, doesn't work and the error below.
Code that works, makes the LED toggle at every falling pin change:
#define PB2_INTERRUPT PORTB.INTFLAGS & PIN2_bm #define PB2_CLEAR_INTERRUPT_FLAG PORTB.INTFLAGS &= PIN2_bm #define PB2_LOW !(PORTB.IN & PIN2_bm) void setup() { PORTA.DIR = PIN7_bm; //sets PA7 to output PORTB.DIR &= ~PIN2_bm; //seta PB2 to input PORTB.PIN2CTRL |=PORT_PULLUPEN_bm; PORTB.PIN2CTRL |=PORT_ISC_FALLING_gc; // enables pull up and configures interrupt for PB2 } void loop() { // put your main code here, to run repeatedly: } ISR(PORTB_PORT_vect) { if(PB2_INTERRUPT) { PORTA.OUT ^=PIN7_bm; //TOGGLES THE led PIN //delay(250); PORTB.INTFLAGS &= PIN2_bm;//PB2_CLEAR_INTERRUPT_FLAG; } }
Code that doesn't work, would like to see this code toggle the LED at every timer compare match:
void setup() { cli(); PORTA.DIR = PIN7_bm; //sets PA7 to output TCB0.CCMP =0xFFFF; //Make the time duration a long as possible TCB0.CTRLA = 1;// Should put a 1 in the Enable bit TCB0.CTRLB = 0; //should be periodic interrupt mode (page 256) TCB0.INTCTRL = 1;//Should enable capture interrupt sei(); } void loop() { // put your main code here, to run repeatedly: } ISR(TCB0_CAPT_vect) //not sure what this should be { PORTA.OUTTGL = PIN7_bm; TCB0.INTFLAGS = 1; // Should clear the interrupt flag }
The data sheet, table 21-4. says that the vector name is CAPT, in the format of peripheral_vectorname_vect seems like TCB0_CAPT_vect is about right...
But here is the error:
:\Users\Bill\Documents\Arduino\testATTINY3216\testATTINY3216.ino:21:5: warning: 'TCB0_CAPT_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr] ISR(TCB0_CAPT_vect)
Any ideas?