Discussion in "AVR Discussion Forum" started by    rayhall    Sep 18, 2013.
Wed Sep 18 2013, 09:57 am
#1
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.
Wed Sep 18 2013, 11:59 am
#2
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:10 pm
#3
[Topic moved to AVR Discussion forum]
Wed Sep 18 2013, 12:38 pm
#4


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
#5
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.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Anthonyklup
Sun May 26 2024, 07:54 pm
Robertbix
Sat May 25 2024, 11:35 pm
cngCar
Fri May 24 2024, 03:50 pm
Jamesdesee
Fri May 24 2024, 02:48 pm
DavidFah
Thu May 23 2024, 06:09 pm
Briandog
Thu May 23 2024, 04:59 pm
RalphTyday
Thu May 23 2024, 03:49 pm
LouisTen
Thu May 23 2024, 01:44 pm