Valid ISR names for -1 series AVRs

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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?

This topic has a solution.

Bill

Last Edited: Thu. Dec 5, 2019 - 03:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That is "TCB0_INT_vect"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

bigginsking wrote:

ISR(TCB0_CAPT_vect)

 

Yep, thats wrong. maybe you should take a look at this app note:

 

AVR1000: Getting Started with Writing C-Code for XMEGA

 

also take a look at the atdf file along with the XML description.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

You can also look at the iotn3216.h file (probably off in a pack directory.)

 

#define TCA0_LUNF_vect      _VECTOR(8)  /*  */
#define TCA0_OVF_vect      _VECTOR(8)  /*  */
#define TCA0_HUNF_vect      _VECTOR(9)  /*  */
#define TCA0_LCMP0_vect      _VECTOR(10)  /*  */
#define TCA0_CMP0_vect      _VECTOR(10)  /*  */
#define TCA0_CMP1_vect      _VECTOR(11)  /*  */
#define TCA0_LCMP1_vect      _VECTOR(11)  /*  */
#define TCA0_CMP2_vect      _VECTOR(12)  /*  */
#define TCA0_LCMP2_vect      _VECTOR(12)  /*  */
#define TCB0_INT_vect      _VECTOR(13)  /*  */
#define TCB1_INT_vect      _VECTOR(14)  /*  */
#define TCD0_OVF_vect      _VECTOR(15)  /*  */
#define TCD0_TRIG_vect      _VECTOR(16)  /*  */

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


Or more generally, ALL the vectors for a 3216:

C:\Program Files (x86)\Atmel\Studio\7.0\packs\atmel\ATtiny_DFP\1.3.229\include\avr>grep _VECTOR iotn3216.h
#define CRCSCAN_NMI_vect      _VECTOR(1)  /*  */
#define BOD_VLM_vect      _VECTOR(2)  /*  */
#define PORTA_PORT_vect      _VECTOR(3)  /*  */
#define PORTB_PORT_vect      _VECTOR(4)  /*  */
#define PORTC_PORT_vect      _VECTOR(5)  /*  */
#define RTC_CNT_vect      _VECTOR(6)  /*  */
#define RTC_PIT_vect      _VECTOR(7)  /*  */
#define TCA0_LUNF_vect      _VECTOR(8)  /*  */
#define TCA0_OVF_vect      _VECTOR(8)  /*  */
#define TCA0_HUNF_vect      _VECTOR(9)  /*  */
#define TCA0_LCMP0_vect      _VECTOR(10)  /*  */
#define TCA0_CMP0_vect      _VECTOR(10)  /*  */
#define TCA0_CMP1_vect      _VECTOR(11)  /*  */
#define TCA0_LCMP1_vect      _VECTOR(11)  /*  */
#define TCA0_CMP2_vect      _VECTOR(12)  /*  */
#define TCA0_LCMP2_vect      _VECTOR(12)  /*  */
#define TCB0_INT_vect      _VECTOR(13)  /*  */
#define TCB1_INT_vect      _VECTOR(14)  /*  */
#define TCD0_OVF_vect      _VECTOR(15)  /*  */
#define TCD0_TRIG_vect      _VECTOR(16)  /*  */
#define AC0_AC_vect      _VECTOR(17)  /*  */
#define AC1_AC_vect      _VECTOR(18)  /*  */
#define AC2_AC_vect      _VECTOR(19)  /*  */
#define ADC0_RESRDY_vect      _VECTOR(20)  /*  */
#define ADC0_WCOMP_vect      _VECTOR(21)  /*  */
#define ADC1_RESRDY_vect      _VECTOR(22)  /*  */
#define ADC1_WCOMP_vect      _VECTOR(23)  /*  */
#define TWI0_TWIS_vect      _VECTOR(24)  /*  */
#define TWI0_TWIM_vect      _VECTOR(25)  /*  */
#define SPI0_INT_vect      _VECTOR(26)  /*  */
#define USART0_RXC_vect      _VECTOR(27)  /*  */
#define USART0_DRE_vect      _VECTOR(28)  /*  */
#define USART0_TXC_vect      _VECTOR(29)  /*  */
#define NVMCTRL_EE_vect      _VECTOR(30)  /*  */
#define _VECTOR_SIZE 4 /* Size of individual vector. */
#define _VECTORS_SIZE (31 * _VECTOR_SIZE)

Another way to access this is to simply start a project in AS7 for 3216. Don't bother to add anything to the empty main() but just build it. As soon as you have you will find:

 

 

In that file just search for "_VECTOR":

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

bigginsking wrote:
Code that works...

ISR(PORTB_PORT_vect)

As you have (at least) one ISR which compiles OK, another possibility to find where the vector names are defined would be to use the IDE's "Go To Definition" facility - it is likely that they will all be in the same place (and previous posts have shown that they are).

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Tue. Dec 3, 2019 - 10:02 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all the great advice, this forum is fantastic.

 

I'm still monkeying with registers to get the timer to work right but I should be able to get that all squared away.

 

 

Bill

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're welcome.

 

If that's resolved the issue, see Tip #5.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...