Change Signal Width
Discussion in "AVR Discussion Forum" started by rayhall Sep 18, 2013.
Wed Sep 18 2013, 09:57 am
Hello,
What I am trying to do is read a square wave signal into the Mega2650, and then send it out on another pin narrower or wider.
I believe output compare can be used. Is this correct, or is there a better way.
Ray.
What I am trying to do is read a square wave signal into the Mega2650, and then send it out on another pin narrower or wider.
I believe output compare can be used. Is this correct, or is there a better way.
Ray.
Wed Sep 18 2013, 11:59 am
yes you can use timer in capture mode with interrupt enabled. so you can measure pulse width. later you can use another time in output compare mode to generate whatever pulse width you want.
Wed Sep 18 2013, 12:38 pm
yes you can use timer in capture mode with interrupt enabled. so you can measure pulse width. later you can use another time in output compare mode to generate whatever pulse width you want.Ajay Bhargav
Thanks for the reply.
I have used input capture before, but never output compare. What mode should be used for this. http://www.tfelectronics.com.au/bin/ModeTable.png
Ray.
Wed Sep 18 2013, 02:46 pm
use mode 4, CTC (clear timer on compare match) with OCRn. also enable interrupt for OCR, so that as soon as a compare occurs you can update OCRn registers to modify pulse width. you can even control individual width of Low/High period.
Powered by e107 Forum System