Posted: Sat May 09, 2015 10:49 pm Post subject: Single pulse from Timer1 in CTC or PWM mode
Hello,
Is it possible to generate a single 10ms pulse from Timer1 (eg OC1B output) with no interrupts in ATMEGA128?
I would like to get purly hardware generated one single 10ms pulse (not a pulse wave) after setting a command/commands for triggering it.
So I am looking for an alternative to this:
Set PORTB.6
Waitms 10
Reset PORTB.6
But without freezeng ATMEGA for 10 ms and without interrupts. CTC or PWM mode could help? Any ideas?
(BASCOM-AVR version : 2.0.7.8 )
Last edited by Pzx on Sun May 10, 2015 8:21 am; edited 2 times in total
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
Posted: Sun May 10, 2015 6:52 am Post subject:
Not really. There is no hardware within the AVR which will generate a single pulse.
What is your objection to using interrupts ?
Interrupts are really the only way to do this, and allow other code to run until the IRQ is trigggered.
Setup a timer with the correct count and prescaler, enable the relevant IRQ, set the line you want to output, start the timer, then within the IRQ reset the line and stop the timer.
At most this should consume a few hundred clocks for the IRQ, probably only 20 or so if you wrote it in ASM.
You should also consider that your main program runs in a loop, so you will ( presumably ) generate that pulse every time around the loop. So in fact you can set up a timer to generate the pulse regularly, and then fit the rest of your program around that interval.
Does this help ? _________________ Adrian Jansen
Computer language is a framework for creativity
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum