Solved: timer ISR for XMEGA A1U with START / ASF4 / Studio 7

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

Goal:

 

I'm starting a project using the XMEGA A1U Xplained Pro board, and I'd like to create an app that simply calls an ISR once every millisecond (or 10 milliseconds, I'm not picky...).

 

Short Question:

 

How do I set up an ISR or callback for the timer interrupt under Atmel START / ASF4?  (More detailed question below)....

 

Environment:

 

Dev Board: XMEGA A1U Xplained Pro

IDE: Atmel Studio 7 (Version 7.0.1931)

Framework: Atmel START Version 1.5.1826

 

What I've tried:

 

In Atmel START, I've created a new project for the XMEGA A1U Xplained Pro.  I added a TIMER_0 instance with the following salient settings:

  • Driver: TC:Init
  • Instance:TCC0
  • Clock: CLK CPU/PER (2 MHz)
  • Period: 2000 (i.e. 1 mSec)
  • Overflow Interrupt Level: Low Level
  • WGMode: Normal Mode

The User Guide for the TIMER_0 instance also mentioned "ISR will be generated only when Global Interrupt checkbox and driver_isr Harnes checkbox are enabled", so in the PMIC module:

  • Global Interrupt Enable checked
  • Include Pin Change ISR harness in driver_isr.c checked

 

Screen capture of the TIMER_0 configuration follows (there must be a better way to format this!):

Screen Shot of Atmel START configuration

 

The START project exports into Atmel Studio 7, compiles and loads without error, but the generated code is (understandably) sparse:

#include <atmel_start.h>

int main(void)
{
	/* Initializes MCU, drivers and middleware */
	atmel_start_init();

	/* Replace with your application code */
	while (1) {
	}
}

 

So now I need to know what is idiomatically correct for ASF4 (and I haven't been able to find code examples): how do I write and install an ISR or callback?  (IIRC ASF4 prefers callbacks over explicit IRS.)  Do I have to enable the timer interrupt explicitly?  Etc...

 

 

Last Edited: Tue. Apr 23, 2019 - 09:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


 

Start with the circled button!

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

@ki0bk

 

Start with the circled button!

 

You'll notice in the OP that I already did!!  :)

 

The User Guide for the TIMER_0 instance also mentioned "ISR will be generated only when Global Interrupt checkbox and driver_isr Harnes checkbox are enabled", so in the PMIC module...

But what I DID discover is that START created a file called driver_asr.c, which contains:

#include <driver_init.h>
#include <compiler.h>

ISR(TCC0_OVF_vect)
{
	/* Insert your Timer Overflow/Underflow Interrupt handling code here */
}

I added just enough code to set breakpoint there and verified that it's getting called periodically.  Solved.

 

Now on to bigger adventures!