TC5 already used in ASF/FreeRTOS samd21g18a?

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

I have a samd21g18a running standalone ASF (not using studio) with FreeRTOS 8.2.3.  I am implementing the tickless feature by changing the system tick as shown:

 

void vPortSetupTimerInterrupt(void)
{
	// Struct for configuring TC
	struct tc_config tcconf;
	// Set up configuration values
	tc_get_config_defaults(&tcconf);
	tcconf.counter_size    = TC_COUNTER_SIZE_32BIT;
	tcconf.run_in_standby  = true;
	tcconf.clock_prescaler = TC_CLOCK_PRESCALER_DIV1;
	tcconf.wave_generation = TC_WAVE_GENERATION_MATCH_FREQ;

	// Initialize the TC
	configASSERT(tc_init(&tc, TC4, &tcconf) == STATUS_OK);

	// Register and enable callback for freeRTOS tick handler
	tc_register_callback(&tc, (tc_callback_t) xPortSysTickHandler, TC_CALLBACK_CC_CHANNEL0);
	tc_enable_callback(&tc, TC_CALLBACK_CC_CHANNEL0);

	// Set top value equal to one os tick
	tc_set_top_value(&tc, TIMER_RELOAD_VALUE_ONE_TICK);

	// Enable the timer
	tc_enable(&tc);
}

 

The default setting was TC5, which won't run properly but TC4 does.  IS TC5 used somewhere in the ASF/FreeRTOS implementation for the samd21?  My searches have come up empty.

 

 

 

 

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

Assuming the tick cannot be using it, as you are implementing your own tick function, then nothing in FreeRTOS will be using it.  Are you using a pre-configured demo app?  If so, is there something in the demo using it?  Sometimes interrupts are used to demonstrate context switching from inside an interrupt.

 

+ http://www.FreeRTOS.org
The de facto standard, downloaded every 170 second during 2019.

 

 

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

Thanks for the response,

 

I am working with a feather m0 board with LoRa from adafruit and writing code based off the ASF/freeRTOS code provided.  I have a USART/debug_print on SERCOM1, and SPI to the LoRA radio on SERCOM4 but nothing else that I have setup "purposely".  I did some searching for TC5 to try and see if there was a config header or something that was assigning it to a different task but didn't find anything.  Sure could be related to an interrupt but nothing I have come across yet.  I have noticed that the SERCOM setup using the ASF default functions can effect pin configurations so I was curious if it can have the sam effect on timers.

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

If anyone is interested, I was just missing the fact that Timer/Counter 4 (TC4) is only 16 bit so when you setup the timer as 32 bit it automatically grabs the next timer and creates a 32 bit timer using TC4 and TC5.  Completely obvious after reading the timer counter datasheet/tutorial for the third time.