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, 10 months ago.
Timer0/ADC
I'm trying to configure Timer0 and the ADC to periodically sample two channels but not having much success. A few questions:
1) The timer code I've seen has the following statement in the interrupt service:
NVIC_ClearPendingIRQ(TIMER0_IRQn);
but the ADC code I've found a similar statement does not appear in the interrupt handler. Should such a statement be in both?
2) My Timer0 code enables External Match 1; that is, MAT0.1 is set high when CR == MCR. When does this bit get reset?
3) When triggered by MAT0.1 I would like the ADC to sample the two channels specified by the bits in the SEL field of ADCR and generate an interrupt when the conversion of the second channel has completed (SEL=3 and ADINTEN=2 to sample ADC0.0 and ADC0.1. I know that multiple channels can be sampled in burst mode but it's not clear to me that this is possible otherwise. Is it?
2 Answers
10 years, 10 months ago.
1. I would guess neither, an interrupt is normally removed via the registers of the peripheral which called it. So in your case timer/ADC.
2. Should be somewhere in the user manual, if you enable it only to go high when it meets the requirements, it will never go low.
3. Do you really need an external match pin for this? Instead of only just generating an internal interrupt. (look at the mbed timer code: http://mbed.org/users/mbed_official/code/mbed-src/file/ca88dd32f209/targets/hal/TARGET_NXP/TARGET_LPC176X/us_ticker.c). I guess for the ADC you probably need to generate an interrupt after the first one is finished, then do the second one. Depending on your sampling time requirements you can also run the ADC in burst mode, and read the values directly once the interrupt happens (but then you don't know exactly when the conversion happened).
10 years, 10 months ago.
Hey Gery! try to go ahead with time & Interrupts Handbook descriptions.
I think mbed have no abstraction for mulitsampling so you have to handle the bits.. simple startup for you with 1 ADC fft_adc.lpc17xx or touchscreen reading. in case of that you need the UserManual for LPC176x if you have an 1768.
regards
note: in UM10360 on page 578 -> you can handle edge selected on PINs p2.10 and P1.27 but this pins are not used internally in the mbed or with Match
MAT0.1 MAT0.3 MAT1.0 and MAT1.1 are can help -> Trigger ADC from Timer Match
posted by 10 Jan 2014