We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I am using cortex-M3. I need to generate a square wave using ADC values. Also i need to change the duty cycle. Already i have used timer program to generate square wave with 16ms of timeperiod. Please help me how to change the program.
Thank You.
Have you already written the code for ADC? You need to divide the ADC range (ADC resolution i.e. Final value) into 16 parts. This 16 parts correspond to total time period of 16msec. (Hence 1part <-> 1msec, 2parts <-> 2msec and so on...) Read the ADC converted value. Check the ADC value falls in which part range. ON time period = 16msec - Part number in which the current value falls.
Thats it!!!
ADC resolution i.e. Final value ADC resolution or Maximum count value corresponding to Vdd volts.
ON time period = 16msec - Part number in which the current value falls. Load the count corresponding to the Timer ON period into 1match register and count corresponding to 16msec in other match register of the same timer. On interrupt, check interrupt due to which match register was generated and accordingly Set/Reset the port pin on which you want to generate the waveform.
What program? What chip?
Could you not just DMA the ADC reading periodically into the timers period or duty registers? Or via and ADC EOC interrupt?