How can I use PWM on ATMEGA2561?

General discussion on mikroPascal for AVR.
Post Reply
Author
Message
ThomasW69
Posts: 3
Joined: 17 Dec 2007 20:21

How can I use PWM on ATMEGA2561?

#1 Post by ThomasW69 » 17 Dec 2007 20:25

How can I use PWM on ATMEGA2561?
I used Bascom before and it was simple to initialize the PWM with

Config Timer1 = Pwm , Pwm = 8 , Compare C Pwm = Clear Up , Compare C Pwm = Clear Down , Prescale = 256

Now I tried Mikropascal with

Pwm_Init(PWM_PHASE_CORRECT_MODE, PWM_PRESCALER_256, PWM_NON_INVERTED, duty);

and I got an compiler error. Is PWM_Init supported on ATMEGA2561?

DaFR34K
Posts: 1
Joined: 26 Feb 2008 23:49
Location: Germany
Contact:

#2 Post by DaFR34K » 27 Feb 2008 00:01

Hi ....


//PWM PortB.7 Init
TCCR0A.WGM00:=1;
TCCR0A.WGM01:=0;
TCCR0B.WGM02:=0;
TCCR0A.com0A0:=0;
TCCR0A.com0A1:=1;
TCCR0B.CS00:=0;
TCCR0B.CS01:=0;
TCCR0B.CS02:=1;

// value for PWM (0=min, 255=max)
OCR0A:= 255;


greetz DaFR34K

PS: i use this code for BackgroundLightControl for Display3000 :wink:

Post Reply

Return to “mikroPascal for AVR General”