| Author |
Message |
|
|
Posted: Jul 03, 2012 - 10:33 AM |
|

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)
{
}
}
|
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 11:19 AM |
|

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.
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 11:48 AM |
|


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
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 12:53 PM |
|

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. |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 01:19 PM |
|

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. |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 10:10 PM |
|

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. |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 10:11 PM |
|

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. |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 10:35 PM |
|

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  |
_________________ Regards,
Steve A.
The Board helps those that help themselves.
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 10:45 PM |
|

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. |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 10:55 PM |
|

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. |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 11:16 PM |
|


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.] |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 11:32 PM |
|

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.
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 11:54 PM |
|


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
|
| |
|
|
|
|
|
Posted: Jul 04, 2012 - 12:04 AM |
|


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
|
| |
|
|
|
|
|
Posted: Jul 04, 2012 - 09:27 AM |
|


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  |
_________________ Atmel Studio 6.1 is now released, grab it here.
Report AS6/ASF bugs here.
|
| |
|
|
|
|
|