This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hello,
I have a problem with event based ADC Interrupt. Currently I used CPU based timer interrupt to see correctness of the configuration, this works fine.
In CPU Interrupt method I can see that the timer works fine, and I also can trigger the ADC once by using generic timer event based zero event trigger, but only once. I already looked at the example "adc12_triggered_by_timer_event" and did almost the same configuration, that's why only get one adc execution call, but I want to get an ADC reading, every time a zero event occurs in the timer, instead of just one ADC call, I looked at many examples but cannot find a solution.
Also when I try to use this I don't want to have every result from start address to end address (e.g 0-10) at once, but I also want to put an interrupt in between two adc timer start and read the adc values (e.g 0-5) after one interrupt and then 6-10 in another interrupt in between those two timer calls. Do I have to change CTL2 Register end address and start address config in the program runtime instead of the init function for that?
Many thanks in advance!
Hi,
I would say yes. I think you need to change CTL2 in program runtime.
But another question is that, why you do not use two ADC0 and ADC1 to achieve your requirement. You can use ADC0 to sample 0-5 signals then use ADC1 to get the rest signals.
Best regards,
Cash Hao
Hi Cash,
thanks for your reply, unfortunately I can't use ADC1, but I will try to change CTL2 in program runtime.
To my question from before, I have found this table
the adc Trigger and sample Mode, on the right of the table are the Event triggers. I try to use Sequence Channels conversion in combination with AUTO. I have some questions that may solve my issue, I would be thankful if you could answer these.
1. do I have to set the ENC bit, every time I want to do a Sampling, or is it automatically covered by zero event Trigger from Timer? If I have to set ENC bit, do I have to set it before or after CTL2 change?
2. In case of the event trigger, Zero event, how can I see whether it works or not, except for using Register View in Debug?
3. do I have to somehow put a conditional statement (e.g. if) to trigger ADC sample or is it really automatically done by Hardware generic event trigger, when Trig bit is set to Event?
4. if zero event occurs do I have to clear it or is it automatically cleared by adc (I connected both FPUB and FSUB)? if I have to clear it, how would I do it?
5. How does the ADC know to which event trigger it shall react to start the sampling, is it done over IMASK in the timer config? Because it is not quite clear, how to tell the ADC the wanted to start sampling.
Thanks in advance.
Hi,
1. In manual mode, you need to set ENC bit for each measurement. And need to set after change on CTL2. In Auto mode, you do not need to set it.
2. I would suggest you to use manual mode and set the ENC bit in the timer interrupt routine. In this case you can see how it works.
3. If ADC is trigger by event, you do not need to put a condition there.
4. You do not need to clear it if you follow the 2nd point method.
5. In manual mode, it is clear that the ENC bit will start an ADC conversion. But for auto mode, I am not sure how the ADC knows it.
Best regards,
Cash Hao