AnsweredAssumed Answered

Systick Priority using USB FS library

Question asked by longchair.m on Aug 25, 2012
Latest reply on Aug 25, 2012 by longchair.m
hello eveyone,

I am currently using USB FS library and also systick interrupt to time some operations in the program. USB library works fine when used, and systick also works fine (used basically to mae some delay Functions or time exexution between code.

my systick interrupt is set at 200khz (5us step increments) with the following code :

#define SYSTICK_FREQUENCY  200000 
SysTick_Config(SystemCoreClock / SYSTICK_FREQUENCY);

What I can observe is that when I send a big amount of of data over the usb taking about 7.5 seconds, I get a number of increments of about 450000, which would make 2 seconds timing.

I therefore suspected that it was an interrupt priority problem.

I checked into the USB FS library code that I was using and what I can see in terms of interrupt configurations is :

 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
 NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

I have seen that the systick_config code was setting interrupt priority to lowest priority, So I have tried to set systick interrupt to highest priority using :

NVIC_SetPriority(SysTick_IRQn, 0);

I have also tried to lower the USB priority values to 5,5 (NVIC_IRQChannelPreemptionPriority, NVIC_IRQChannelSubPriority ), but the problem still remains the same.

How can I make sure that teh systick interrupt will still be higher priority and evntually preempt any other interrupt so that my time measurement interrupt still gives reliable values ?

Thanks in advance.

LongChair.

Outcomes