Timer example not working for timer value in micro seconds on MQX 3.6.1 MCF52259evb

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timer example not working for timer value in micro seconds on MQX 3.6.1 MCF52259evb

Jump to solution
1,308 Views
prvermas
Contributor I

Hi All,

I am not able to invoke a timer function that has a granularity of microseconds. I tried using following original code

   _timer_create_component(TIMER_TASK_PRIORITY, TIMER_STACK_SIZE);

   _time_init_ticks(&dticks, 0);

   _time_add_sec_to_ticks(&dticks, 2);

   _time_get_elapsed_ticks(&ticks);

   _time_add_sec_to_ticks(&ticks, 1);

   on_timer = _timer_start_periodic_at_ticks(LED_on, 0,

      TIMER_ELAPSED_TIME_MODE, &ticks, &dticks);

   _time_add_sec_to_ticks(&ticks, 1);

   off_timer = _timer_start_periodic_at_ticks(LED_off, 0,

      TIMER_ELAPSED_TIME_MODE, &ticks, &dticks);

I tried by invoking the api _time_add_usec_to_ticks & all other parameters remaining the same. Kindly help me out with the things that I am missing out for the desired result of a periodic timer at 100 microseconds(say)

Best Regards,

0 Kudos
1 Solution
725 Views
soledad
NXP Employee
NXP Employee

Hi,

It is very difficult to generate such short interrupts in MQX. This is because the "tick" which is the smallest base time unit is 10 ms as default. All interrupts are based on the tick ad it is not possible to generate a shorter one that 10ms. You can modify the tick but we cannot guarantee a proper performance aunder modified conditions. Delays are calculted in the following way: # of ticks = # of miliseconds requested x ( # of ticks per second / 1000 miliseconds) For example, if BSP_ALARM_FREQUENCY is set as default (100) and you request a 55ms delay you will have: 55ms x (100 ticks / 1000ms) = 5.5 ticks This value will be truncated to 5 ticks. If you request any delay from 0 to 9 ms you will have 0 ticks. But you will have some latency delay. You can edit BSP_ALARM_FREQUENCY in order to have smaller ticks, but as i mentioned above, we cannot guarantee the correct behavior if you modify original settings.

Another option is using the GPT, please check the attached example.

Please add this define to the C:\Program Files\Freescale\Freescale MQX 3.6\config\m52259demo\user_config.h file:

#define MQX_ROM_VECTORS  0

You have to tell MQX that the vectors are not in ROM and then the function _int_install_kernel_isr can install the function correctly.

Don’t forget to recompile your libraries after that. Open and compile this project after you modify the user_config.h in order to have all your libraries recompiled.


Have a great day,
Regards
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
2 Replies
726 Views
soledad
NXP Employee
NXP Employee

Hi,

It is very difficult to generate such short interrupts in MQX. This is because the "tick" which is the smallest base time unit is 10 ms as default. All interrupts are based on the tick ad it is not possible to generate a shorter one that 10ms. You can modify the tick but we cannot guarantee a proper performance aunder modified conditions. Delays are calculted in the following way: # of ticks = # of miliseconds requested x ( # of ticks per second / 1000 miliseconds) For example, if BSP_ALARM_FREQUENCY is set as default (100) and you request a 55ms delay you will have: 55ms x (100 ticks / 1000ms) = 5.5 ticks This value will be truncated to 5 ticks. If you request any delay from 0 to 9 ms you will have 0 ticks. But you will have some latency delay. You can edit BSP_ALARM_FREQUENCY in order to have smaller ticks, but as i mentioned above, we cannot guarantee the correct behavior if you modify original settings.

Another option is using the GPT, please check the attached example.

Please add this define to the C:\Program Files\Freescale\Freescale MQX 3.6\config\m52259demo\user_config.h file:

#define MQX_ROM_VECTORS  0

You have to tell MQX that the vectors are not in ROM and then the function _int_install_kernel_isr can install the function correctly.

Don’t forget to recompile your libraries after that. Open and compile this project after you modify the user_config.h in order to have all your libraries recompiled.


Have a great day,
Regards
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
726 Views
prvermas
Contributor I

@soledad

Thanks for your prompt reply, Actually I also modified the timer ticks from 200 (this is the existing one in the the example code library ) to 4000(to get a periodic interrupt at 250 microseconds) but was implementing it at different file my bad :-(

But any how, good that I asked this question I can implement other way as you suggested. Once again thanks for the valuable solution

Best Regards

0 Kudos