10 posts / 0 new
Last post
Rony
Offline
Last seen:4 years 10 months ago
Master
Joined:2014-05-15 15:02
Timer interrupts

So far we have been using app_timer_set to be called periodically. It works fine except that the highest frequency is 100hz.
我们需要calle方式d at about 10Khz and I understand we have to use the timer interrupts
.
Can you provide me an example of how it is done and which drivers we have to include?
Thks

yassin.bennaceur
Offline
Last seen:5 years 9 months ago
Joined:2015-04-10 15:32
I am as well looking for

I am as well looking for using timer0 with 10Khz ? any answer for this.

JE_Dialog
Offline
Last seen:3 weeks 2 days ago
Staff
Joined:2013-12-05 14:02
Hi Yassin, can you describe a

Hi Yassin, can you describe a little bit more about what you want to acheive and I will have one of the team take a look at the best way to achieve. BR JE_Dialog

yassin.bennaceur
Offline
Last seen:5 years 9 months ago
Joined:2015-04-10 15:32
I want to measure ADC with a

I want to measure ADC with a 10Kh frequency using a timer0 interrupt.

I fallowed the PWM example and changed the core of the callback function to do so ... but after several trials I failed to do so.

The thing is that the call back function is never called though I registered ut the way the example does ... I suppose I am missing something here and I just dont know what ?

RvA
Offline
Last seen:2 days 6 hours ago
Staff
Joined:2014-02-07 14:10
Hi Yassin, I am looking into

Hi Yassin, I am looking into your question and will get back to you as soon as possible.

Best regards, RvA

yassin.bennaceur
Offline
Last seen:5 years 9 months ago
Joined:2015-04-10 15:32
Thank you for your support

Thank you for your support and effort.

RvA
Offline
Last seen:2 days 6 hours ago
Staff
Joined:2014-02-07 14:10
Hi Yassin,

Hi Yassin,

In the SDK are some functions you can work with to implement the wanted behavior. The picture below shows the functions that generate the interrupt and the handling of the interrupt:

  • void timer0_test(void) in the pwm_test.c. // CONFIGURATION OF THE TIMER0 TO INTERRUPT EVERY 50sec
  • void SWTIM_Handler(void) in the pwm.c. // interrupt every 50 usec. THIS IS THE PLACE WHERE YOU MUST ADD THE ADC READING.

In the picture below the timing of this is shown:

Best regards, RvA

yassin.bennaceur
Offline
Last seen:5 years 9 months ago
Joined:2015-04-10 15:32
Thanks you very Much RvA,

Thanks you very Much RvA,

This is so helpful,

I used a temporary solution (the sysTick interrupt handler) For now, it work But i will try using your implementation for Timer0 interrupt.

thanks again for your help and support.

yassin.bennaceur
Offline
Last seen:5 years 9 months ago
Joined:2015-04-10 15:32
So I run your code ... But It

So I run your code ... But It did not manage to trigger the interrupt at all...

I was wondering if there is something else I should be configuring ... like no sleep mode or any thing else.

yassin.bennaceur
Offline
Last seen:5 years 9 months ago
Joined:2015-04-10 15:32
你能请吗

你能请吗the code for periph_init() function ?