Yahoo Groups archive

AVR-Chat

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

Thread

Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8

Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8

2005-11-09 by Loren Boyle

Hi Martin.

I played with PWM on the Mega 8 for hours on the simulator trying to find 
what I was doing wrong.  I finally found somewhere that the PWM does not 
work for the Mega 8 (or even the 168) with the simulator(studio 4).  I 
finally did what I thought must be right and stuck it in the chip and it 
worked correctly.

Good luck

Loren





Dave Hylands <dhylands@gmail.com> 
Sent by: AVR-Chat@yahoogroups.com
Nov 09, 2005 03:35 PM
Please respond to
AVR-Chat@yahoogroups.com


To

AVR-Chat@yahoogroups.com
cc





Subject
Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8






Hi Martin,

> I'm having what I can only classify as annoying.  I implemented a simple 
servo controller with a tiny 15 ( two position ) and it worked perfectly. 
I've also done some simple PWM stuff with Timer 2 on the Mega 8.  Now, 
however I need to use the 16 bit timer to generate PWM.  I need a bare 
minimum of 12 bits precision but more would be better ( 256 servo 
positions, 60 Hz update rate ).  To that end I've tried to get 16 bit 
phase and frequency correct PWM working and I've had no luck.  In the 
simulator the timer counts up to TOP (in my case 0xFFFE ) and promptly 
overflows to zero.  Now it's my understanding that it is supposed to count 
up then down ( certainly that's how it works in 8 bit mode ).  It wouldn't 
bug me so much, it overflowing, if I was able to get something useful out 
of it.  However because it is overflowing the output pin is only getting 
set or cleared ( depending on the setting of the COM1nX pins ).  Following 
is the code I use to initialize it.

I wrote some code for the ATMega128 which uses Timer3, but it should
work on Timer1 with a minor tweak (changing the SERVO_1 and SERVO_2
definitions to be 1A and 1B rather than 3A and 3B).. It uses the Fast
PWM mode runs the timer at 2MHz, which means it will overflow every
32.7 msec (or 30.5 times per second).

The sample code can be found here:
<http://websvn.gumstix.com/listing.php?repname=Buildroot&path=%2Fbranches%2Fprojects%2Frobostix%2F&rev=0&sc=0>

You'll be prompted for a username and password, use the word gumstix for 
both.

To get the complete example to build, you'll need the Common
directory, the Simple-Servo directory, and the Rules.mk file.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/



 
Yahoo! Groups Links

Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8

2005-11-10 by Dennis

What timer were you using in the simulator? I'm using T0 in the 168 and I can load it & introduce an interrupt. The interrupt is cleared but there is no vector to the ISR.
Dennis
Show quoted textHide quoted text
----- Original Message -----
Sent: Wednesday, November 09, 2005 5:56 PM
Subject: Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8


Hi Martin.

I played with PWM on the Mega 8 for hours on the simulator trying to find what I was doing wrong. I finally found somewhere that the PWM does not work for the Mega 8 (or even the 168) with the simulator(studio 4). I finally did what I thought must be right and stuck it in the chip and it worked correctly.

Good luck

Loren




Dave Hylands
Sent by: AVR-Chat@yahoogroups.com

Nov 09, 2005 03:35 PM Please respond to
AVR-Chat@yahoogroups.com

To
AVR-Chat@yahoogroups.com cc Subject Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8




Hi Martin,

> I'm having what I can only classify as annoying. I implemented a simple servo controller with a tiny 15 ( two position ) and it worked perfectly. I've also done some simple PWM stuff with Timer 2 on the Mega 8. Now, however I need to use the 16 bit timer to generate PWM. I need a bare minimum of 12 bits precision but more would be better ( 256 servo positions, 60 Hz update rate ). To that end I've tried to get 16 bit phase and frequency correct PWM working and I've had no luck. In the simulator the timer counts up to TOP (in my case 0xFFFE ) and promptly overflows to zero. Now it's my understanding that it is supposed to count up then down ( certainly that's how it works in 8 bit mode ). It wouldn't bug me so much, it overflowing, if I was able to get something useful out of it. However because it is overflowing the output pin is only getting set or cleared ( depending on the setting of the COM1nX pins ). Following is the code I use to initialize it.

I wrote some code for the ATMega128 which uses Timer3, but it should
work on Timer1 with a minor tweak (changing the SERVO_1 and SERVO_2
definitions to be 1A and 1B rather than 3A and 3B).. It uses the Fast
PWM mode runs the timer at 2MHz, which means it will overflow every
32.7 msec (or 30.5 times per second).

The sample code can be found here:


You'll be prompted for a username and password, use the word gumstix for both.

To get the complete example to build, you'll need the Common
directory, the Simple-Servo directory, and the Rules.mk file.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/


------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/dN_tlB/TM
--------------------------------------------------------------------~->


Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AVR-Chat/

<*> To unsubscribe from this group, send an email to:
AVR-Chat-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/





Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8

2005-11-10 by Loren Boyle

Hi Dennis.

I have had no problem getting the times to simulate in the output
compare and input capture modes but when it comes to the various PWM
modes I have had not success with the simulator.

Loren




                                                                        
             "Dennis"                                                   
             <dkazar@sbcgloba                                           
             l.net>                                                  To 
             Sent by:                 <AVR-Chat@yahoogroups.com>        
             AVR-Chat@yahoogr                                        cc 
             oups.com                                                   
                                                                Subject 
                                      Re: [AVR-Chat] Phase and          
             Nov 09, 2005             Frequency Correct PWM on a Mega 8 
             06:25 PM                                                   
                                                                        
                                                                        
              Please respond                                            
                    to                                                  
             AVR-Chat@yahoogr                                           
                 oups.com                                               
                                                                        
                                                                        




What timer were you using in the simulator? I'm using T0 in the 168 and
I can load it & introduce an interrupt. The interrupt is cleared but
there is no vector to the ISR.
Dennis

Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8

2005-11-10 by Dennis

Atmel Norway is looking at the problem. FAE from Dallas is over there as we 
speak. Has ICE and 168 parts.
Should hear from him either today or tomorrow.
Dennis
----- Original Message ----- 
Show quoted textHide quoted text
From: "Loren Boyle" <Loren_Boyle@bcit.ca>
To: <AVR-Chat@yahoogroups.com>
Sent: Thursday, November 10, 2005 11:02 AM
Subject: Re: [AVR-Chat] Phase and Frequency Correct PWM on a Mega 8


>
>
>
>
> Hi Dennis.
>
> I have had no problem getting the times to simulate in the output
> compare and input capture modes but when it comes to the various PWM
> modes I have had not success with the simulator.
>
> Loren
>
>
>
>
>
>             "Dennis"
>             <dkazar@sbcgloba
>             l.net>                                                  To
>             Sent by:                 <AVR-Chat@yahoogroups.com>
>             AVR-Chat@yahoogr                                        cc
>             oups.com
>                                                                Subject
>                                      Re: [AVR-Chat] Phase and
>             Nov 09, 2005             Frequency Correct PWM on a Mega 8
>             06:25 PM
>
>
>              Please respond
>                    to
>             AVR-Chat@yahoogr
>                 oups.com
>
>
>
>
>
>
> What timer were you using in the simulator? I'm using T0 in the 168 and
> I can load it & introduce an interrupt. The interrupt is cleared but
> there is no vector to the ISR.
> Dennis
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>

Re: Phase and Frequency Correct PWM on a Mega 8

2005-11-11 by Dave Mucha

--- In AVR-Chat@yahoogroups.com, "Dennis" <dkazar@s...> wrote:
>
> Atmel Norway is looking at the problem. FAE from Dallas is over
there as we 
> speak. Has ICE and 168 parts.
> Should hear from him either today or tomorrow.
> Dennis

Norway has Ice ?

Re: [AVR-Chat] Re: Phase and Frequency Correct PWM on a Mega 8

2005-11-11 by Dennis

Rats too. Good window shopping I hear.
D
----- Original Message ----- 
Show quoted textHide quoted text
From: "Dave Mucha" <dave_mucha@yahoo.com>
To: <AVR-Chat@yahoogroups.com>
Sent: Thursday, November 10, 2005 7:01 PM
Subject: [AVR-Chat] Re: Phase and Frequency Correct PWM on a Mega 8


> --- In AVR-Chat@yahoogroups.com, "Dennis" <dkazar@s...> wrote:
>>
>> Atmel Norway is looking at the problem. FAE from Dallas is over
> there as we
>> speak. Has ICE and 168 parts.
>> Should hear from him either today or tomorrow.
>> Dennis
>
> Norway has Ice ?
>
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>

Re: [AVR-Chat] Re: Phase and Frequency Correct PWM on a Mega 8

2005-11-11 by Zack Widup

On Fri, 11 Nov 2005, Dave Mucha wrote:

> --- In AVR-Chat@yahoogroups.com, "Dennis" <dkazar@s...> wrote:
> >
> > Atmel Norway is looking at the problem. FAE from Dallas is over
> there as we
> > speak. Has ICE and 168 parts.
> > Should hear from him either today or tomorrow.
> > Dennis
> 
> Norway has Ice ?
> 

Yep.  Not sure if they have tundrastorms, though.  :-)

Zack

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.