ATSAMD21 ATMEL START timer task/external interrupts not executing - driving me nuts!!!!

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

Using ATSAMD21G18, output pin is working, main while loop working, tried debugging, none of the timer tasks or external interrupt functions execute!!!!!

This is driving me crazy, not sure what to do next.

 

Here's the driver code, ANY execution should switch PA01 to 1, light up the LED, put my scope on high, ...all that. In fact, NOTHING HAPPENS!!!! Not my first rodeo with Atmels, my first rodeo with ATSAMD21.

 

/*
 * Code generated from Atmel Start.
 *
 * This file will be overwritten when reconfiguring your Atmel Start project.
 * Please copy examples or other code you want to keep to a separate file
 * to avoid losing it when reconfiguring.
 */

#include "driver_examples.h"
#include "driver_init.h"
#include "utils.h"

static void button_on_PA04_pressed(void)
{
		REG_PORT_OUTSET0 = PORT_PA01;
// 		REG_PORT_OUTCLR0 = PORT_PA01;
}

static void button_on_PA05_pressed(void)
{
		REG_PORT_OUTSET0 = PORT_PA01;
// 		REG_PORT_OUTCLR0 = PORT_PA01;
}

static void button_on_PB22_pressed(void)
{
		REG_PORT_OUTSET0 = PORT_PA01;
// 		REG_PORT_OUTCLR0 = PORT_PA01;
}

/**
 * Example of using EXTERNAL_IRQ_0
 */
void EXTERNAL_IRQ_0_example(void)
{

	ext_irq_register(PIN_PA04, button_on_PA04_pressed);
	ext_irq_register(PIN_PA05, button_on_PA05_pressed);
	ext_irq_register(PIN_PB22, button_on_PB22_pressed);
}

static struct timer_task TIMER_0_task1, TIMER_0_task2;

/**
 * Example of using TIMER_0.
 */
static void TIMER_0_task1_cb(const struct timer_task *const timer_task)
{
		REG_PORT_OUTSET0 = PORT_PA01;
// 		REG_PORT_OUTCLR0 = PORT_PA01;
}

static void TIMER_0_task2_cb(const struct timer_task *const timer_task)
{
		REG_PORT_OUTSET0 = PORT_PA01;
// 		REG_PORT_OUTCLR0 = PORT_PA01;
}

void TIMER_0_example(void)
{
	TIMER_0_task1.interval = 100;
	TIMER_0_task1.cb       = TIMER_0_task1_cb;
	TIMER_0_task1.mode     = TIMER_TASK_REPEAT;
	TIMER_0_task2.interval = 200;
	TIMER_0_task2.cb       = TIMER_0_task2_cb;
	TIMER_0_task2.mode     = TIMER_TASK_REPEAT;

	timer_add_task(&TIMER_0, &TIMER_0_task1);
	timer_add_task(&TIMER_0, &TIMER_0_task2);
	timer_start(&TIMER_0);
}

 

This topic has a solution.

Last Edited: Tue. Nov 24, 2020 - 06:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, solved the timer, function was never called(!).

 

TIMER_0_example(void)

Added function calls from main file, outside the while loop. Time tasks seem to be ok.

 

PA04 working, PA05 still not working, PB22 not working.

 

Any help would be appreciated, I must be missing something here.

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


Any problems with this setup?

 

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

Here's the main.c code:

 

#include <atmel_start.h>
#include <driver_examples.h>

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

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

 

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


Last piece of the puzzle... forgot to fully enable the interrupts in Atmel START.