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

scaneraNom
Sat May 04 2024, 02:21 am
gtaletrzua
Fri May 03 2024, 10:55 am
Clydehet
Wed May 01 2024, 06:44 pm
Davidoried
Wed May 01 2024, 06:11 pm
KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am