Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 11 months ago.
ADC missing a sample??interrupt priority??
hhok
1 Answer
10 years, 11 months ago.
Which one is supposed to have a higher priority? Now the interruptin has higher priority: Lower number = higher priority.
And anyway is it supposed to reset the sampling period each time you got a rising edge? Even with higher priority for the ADC I think you keep the problem. Lets say your period was just a tiny bit too long. Then right before the ADC interrupt would be called, the flip interrupt is called. This sets the Ticker to start roughly 0.02/32 seconds later, while if the original would have kept running it would have called the ADC interrupt 10us later. So you have a gap.
I was giving higher priority to the rising edge interrupt and yes i was looking to update the sampling period with each rising edge interrupt.
It seems to work quite well tho except for maybe once every 4 wave forms it will miss a sample, I understand what you are saying do you know of any work around which could be used to minimize this gap that's being created?
posted by 01 Dec 2013If you would want to do it with this method, two options, which can also be used both:
Option 1, also save time codes, then at least you can restore the original waveform
Option 2, store the time code of the last sample with your ADC sample function. Then in the flip function, check if the last sample was made recently (then do nothing and just set the new period), or if it was quite a long time ago (relative to the period), then soon it would be called to make another sample. In that case manually call the ADC function before setting the ticker.
posted by 01 Dec 2013