Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic Printable version Log in to check your private messages View next topic
Author Message
rayhall
PostPosted: Jul 03, 2012 - 10:33 AM
Hangaround


Joined: Feb 11, 2007
Posts: 200
Location: Cairns, Australia

I am using the Mega168 at 8 MHz, with Timer2 as PWM. Mode 2 (CTC OCRA Immediate) is begin used, to produce a PWM from 10hz to 500hz. I get no output on pin PD3.

Ray.


Code:
#include <avr/io.h>
#include <avr/interrupt.h>

int main(void)
{
      
    DDRD |= (1 << DDD3);   // PD3 OC2B
   ASSR = 0x00;
   OCR2A = 125;
   OCR2B = 100;
   TCNT2 = 80;
   TCCR2A = (1<<COM2B1) | (1<<COM2B0) | (1<<WGM21);  // CTC OCRA Immediate
   TCCR2B = (1<<CS20) | (1<<CS21); // clk/32
   TIMSK2 = 0x00;

    sei(); // Enable Global Interrupts
   
   while(1)
    {


   }

}
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Jul 03, 2012 - 11:19 AM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

Code:
sei(); // Enable Global Interrupts
Why? What for? Who will service it - your uncle or Uncle Sam?

_________________
Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.
 
 View user's profile Send private message  
Reply with quote Back to top
sternst
PostPosted: Jul 03, 2012 - 11:48 AM
Raving lunatic


Joined: Jul 23, 2001
Posts: 2437
Location: Osnabrueck, Germany

rayhall wrote:
I get no output on pin PD3.
What exactly means "no output"? What output do you expect?
With your setup there will be only one single transition from low to high a short time after starting the timer, and then nothing more until you reset the controller.

_________________
Stefan Ernst
 
 View user's profile Send private message  
Reply with quote Back to top
Kartman
PostPosted: Jul 03, 2012 - 12:53 PM
Raving lunatic


Joined: Dec 30, 2004
Posts: 8723
Location: Melbourne,Australia

Ray, do you want pwm or variable frequency? If you want variable frequency, use the CTC mode.
 
 View user's profile Send private message  
Reply with quote Back to top
Kartman
PostPosted: Jul 03, 2012 - 01:19 PM
Raving lunatic


Joined: Dec 30, 2004
Posts: 8723
Location: Melbourne,Australia

try:

TCCR2A = (1<<COM2B0) | (1<<WGM21);

CTC mode with output toggle. You selected output high on match.
 
 View user's profile Send private message  
Reply with quote Back to top
rayhall
PostPosted: Jul 03, 2012 - 10:10 PM
Hangaround


Joined: Feb 11, 2007
Posts: 200
Location: Cairns, Australia

Quote:
Why? What for? Who will service it - your uncle or Uncle Sam?


Smart Ass useless replys are part of the problem on this forum. If you have noting usefull to add, then go away.

Ray.
 
 View user's profile Send private message  
Reply with quote Back to top
rayhall
PostPosted: Jul 03, 2012 - 10:11 PM
Hangaround


Joined: Feb 11, 2007
Posts: 200
Location: Cairns, Australia

Quote:
Ray, do you want pwm or variable frequency? If you want variable frequency, use the CTC mode.


I want to vary the frequency from 10hz to 500hz. Duty will be 50% at all times.

Ray.
 
 View user's profile Send private message  
Reply with quote Back to top
Koshchi
PostPosted: Jul 03, 2012 - 10:35 PM
10k+ Postman


Joined: Nov 17, 2004
Posts: 13815
Location: Vancouver, BC

Quote:
your uncle or Uncle Sam?
The OP is Australian, so it is no likely to be Uncle Sam. My guess is Bob Very Happy

_________________
Regards,
Steve A.

The Board helps those that help themselves.
 
 View user's profile Send private message  
Reply with quote Back to top
rayhall
PostPosted: Jul 03, 2012 - 10:45 PM
Hangaround


Joined: Feb 11, 2007
Posts: 200
Location: Cairns, Australia

Quote:
The OP is Australian, so it is no likely to be Uncle Sam. My guess is Bob


I asked for help, and now as usual I am being used for your entertainment. Will be sending this to Atmel to further complain about Atmel support.
 
 View user's profile Send private message  
Reply with quote Back to top
Kartman
PostPosted: Jul 03, 2012 - 10:55 PM
Raving lunatic


Joined: Dec 30, 2004
Posts: 8723
Location: Melbourne,Australia

Ray, you got your answer. Not even thanks for the effort i put in reading the datasheet for you. Maybe i should lodge a complaint at rayhall.support for poor manners.
 
 View user's profile Send private message  
Reply with quote Back to top
theusch
PostPosted: Jul 03, 2012 - 11:16 PM
10k+ Postman


Joined: Feb 19, 2001
Posts: 25881
Location: Wisconsin USA

Quote:

Will be sending this to Atmel to further complain about Atmel support.

??? Now I'm >>way<< confused. If you wanted support directly from Atmel for your AVR question, why didn't you send it to Atmel directly instead of posting on an open forum? After all, your complaint will be going to the same email address, won't it?

As your original post has [nearly] all the stuff I'm looking for, and the sei() given the entire program is benign, our old friend MBedder must have been casting about for underlings to flog. Pay no attention. [The missing piece is the toolchain (and version) but that can be inferred.]
 
 View user's profile Send private message  
Reply with quote Back to top
Koshchi
PostPosted: Jul 03, 2012 - 11:32 PM
10k+ Postman


Joined: Nov 17, 2004
Posts: 13815
Location: Vancouver, BC

Quote:
I asked for help, and now as usual I am being used for your entertainment.
I was mocking mbedder, not you.

_________________
Regards,
Steve A.

The Board helps those that help themselves.
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Jul 03, 2012 - 11:54 PM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20311
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Quote:
Will be sending this to Atmel to further complain about Atmel support.
I'll lock this thread then, if Atmel supports wants to reopen it they can do so.

It's amazing that anyone is ready to try and help you with your attitude and the attitude you have shown in the past.

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
EW
PostPosted: Jul 04, 2012 - 12:04 AM
Raving lunatic


Joined: Mar 01, 2001
Posts: 4951
Location: Rocky Mountains

MBedder wrote:
Code:
sei(); // Enable Global Interrupts
Why? What for? Who will service it - your uncle or Uncle Sam?


No matter how the OP has acted in the past, please do not post snide remarks.

It is better to walk away and say nothing then to continue to add to the problem.

_________________
Eric Weddington
Marketing Manager
Open Source & Community
Atmel
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
abcminiuser
PostPosted: Jul 04, 2012 - 09:27 AM
Moderator


Joined: Jan 23, 2004
Posts: 9817
Location: Trondheim, Norway

Hi Ray, I just received your support request ticket.

I'll respond later today once I have some time, but please keep in mind that this is a community forum of volunteers, thus while sarcastic responses are undesirable we aren't going to shut down the forums because they crop up occasionally.

- Dean Twisted Evil

_________________
Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits