Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] Can someone double check my assumptions ATMega128 PWM

2005-02-07 by wbounce

This turns out to have been a header pin with a bad connection of the
PWM pin. This meant the left side was getting 100% because the pwm pin
was pulled high with pull up resistors. 

-----Original Message-----
From: Brian Dean [mailto:bsd@bdmicro.com] 
Sent: Friday, January 28, 2005 10:43 PM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Can someone double check my assumptions
ATMega128 PWM



On Fri, Jan 28, 2005 at 06:54:31PM -0500, wbounce wrote:

> void initmotor(void)
> {
> OCR3A = 0;
> OCR3B = 0;
> 
> TCCR3A = BV(WGM31) | BV(WGM30) ; /* set timer/counter 3 to fast PWM 
> mode 7 */ TCCR3A |= BV(COM3A1) | BV(COM3B1); /* Clear OCnA/OCnB/OCnC 
> on compare match when up-counting. */
> TCCR3B = BV(CS30) | BV(WGM32) ; /* prescale: 1 @ 16 MHz, 10 bit PWM
> overflows @ 15625 HZ */
> 
> // turn everything off
> OCR3A = 0;
> OCR3B = 0;
> 
> DDRE |= BV(PORTE3)|BV(PORTE4); /* enable PWM outputs */
> }
> According to how I read the data sheet this should be setting up (Page

> 133) Mode 7 fast PWM 10 bit with no prescale which should give me 
> 15.6K PWM
> 
> And setting COM3A1 and COM3B1 should turn the pin to 0 when the 
> counter hits the value I set in OCR3A or OCR3B?
> 
> Is this COM3A1 part correct?

Your code looks correct.  Do you have a scope to double check the output
waveform?

-Brian
-- 
Brian Dean
BDMICRO - ATmega128 Based MAVRIC Controllers http://www.bdmicro.com/


 
Yahoo! Groups Links

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.