Should I (avoid to) modify the ASF driver code ?

Discussions around product based on ARM Cortex M0+ core.

Moderator: nferre

terbo
Posts: 26
Joined: Sun Oct 06, 2013 11:04 pm

Should I (avoid to) modify the ASF driver code ?

Fri Jun 27, 2014 2:02 pm

Hi.
Some Q's regarding ASF code usage. To be specific:
I want to use SysTick as a 1 msec interrupt timer. When the SysTick timer interrup occur, I want to be "transferred" to the SysTick ISR (automatically). In the ASF generated file samd20j18.h we have the definition:
#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */
I guess I have to call the SysTick_Config(..) routine as defined in file core_cm0plus.h, so I have to set/modify __Vendor_SysTickConfig to 1 in the ASF generated file samd20j18.h.

Q-1: Is it good practice to modify the ASF generated files?
Q-2: Is this (#define __Vendor_SysTickConfig 0) maybe due to wrong setting in the ASF-Wizard when I generated my system (I really want 1 msec interrupts using SysTick)?
Q-3: Where (in which file) do I specify my "SysTickISR" to the exception handeling system ?
Q-4: Other valuable comments regarding this issue ?
Regards Terje
pozz
Posts: 67
Joined: Fri Jun 13, 2014 2:55 pm

Re: Should I (avoid to) modify the ASF driver code ?

Mon Jun 30, 2014 4:26 pm

terbo wrote: In the ASF generated file samd20j18.h we have the definition:

Code: Select all

#define __Vendor_SysTickConfig 0         /*!< Set to 1 if different SysTick Config is used */
I guess I have to call the SysTick_Config(..) routine as defined in file core_cm0plus.h, so I have to set/modify __Vendor_SysTickConfig to 1 in the ASF generated file samd20j18.h.
I already used SysTick_Config() without changing __Vendor_SysTickConfig to 1. It works, but I don't know if it's only a coincidence.

I think Atmel doesn't set __Vendor_SysTickConfig in its ASF-generated files (samd20j18.h and similar), because it doesn't provide a vendor-specific configuration function for SysTick.

Look at LED_TOGGLE example project:

Code: Select all

static void configure_systick_handler(void)
{
	SysTick->CTRL = 0;
	SysTick->LOAD = 999;
	SysTick->VAL  = 0;
	SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
}
This function is at the application level (not ASF level) and it's very similar to standad CMSIS SysTick_Config():

Code: Select all

__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
  if (ticks > SysTick_LOAD_RELOAD_Msk)  return (1);            /* Reload value impossible */

  SysTick->LOAD  = (ticks & SysTick_LOAD_RELOAD_Msk) - 1;      /* set reload register */
  NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);  /* set Priority for Systick Interrupt */
  SysTick->VAL   = 0;                                          /* Load the SysTick Counter Value */
  SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |
                   SysTick_CTRL_TICKINT_Msk   |
                   SysTick_CTRL_ENABLE_Msk;                    /* Enable SysTick IRQ and SysTick Timer */
  return (0);                                                  /* Function successful */
}
terbo wrote: Q-1: Is it good practice to modify the ASF generated files?
I think it's not a good practive, even if I don't know how to use ASF with a custom board.
terbo wrote: Q-2: Is this (#define __Vendor_SysTickConfig 0) maybe due to wrong setting in the ASF-Wizard when I generated my system (I really want 1 msec interrupts using SysTick)?
I dont' think so.
terbo wrote: Q-3: Where (in which file) do I specify my "SysTickISR" to the exception handeling system ?
Where you want. But the ISR function name should be SysTick_Handler().

Return to “SAM D20 Cortex-M0+ MCU”

Who is online

Users browsing this forum: No registered users and 1 guest