Hardware way to sync 328 timer0 and timer1?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to play with 3 channel pwm out, so I thinks: set xtal fuse for full swing osc, jumper xtal1 to pd4 and pd5 (t0 and t1 ext clk inputs), and now I have 4 8 bit pwms all running in sync. Clever? Stupid? Some unseen problem?

 

This topic has a solution.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

They share the same prescaler and that has a reset that should allow you to synchronize. No need for external connections to T0, T1.

Regards,
Steve A.

The Board helps those that help themselves.

Last Edited: Sat. Jan 24, 2015 - 04:25 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

T0 and T1 must be driven slower than CLK/2, so this wouldn't work.  As Koshchi says, you can use the TSM bit in GTCCR:

GTCCR = (1<<TSM);
TCCR0A = your_mode_bits;
TCCR0B = your_mode_bits | your_prescaler_bits;
TCCNT0 = 0;
TCCR1A = your_mode_bits;
TCCR1B = your_mode_bits | your_prescaler_bits;
TCCNT1 = 0;
GTCCR = 0;

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]