PWM16bit_Init don't work w/ ATMEGA644P

General discussion on mikroBasic PRO for AVR.
Post Reply
Author
Message
mpfister
Posts: 2
Joined: 30 Mar 2011 11:22

PWM16bit_Init don't work w/ ATMEGA644P

#1 Post by mpfister » 28 Apr 2011 17:13

Actually I'm working with an EasyAVR6-Board and mikroBasic Vers. 4.6. I tried to initialize PWM16 on a ATMEGA644P @ 8MHz with the following code:

PWM16bit_Init(_PWM16_PHASE_CORRECT_MODE_10BIT, _PWM16_PRESCALER_16bit_8, _PWM16_NON_INVERTED, 125, _TIMER1)
PWM16bit_Start( _TIMER1 )

Checking the relevant registers via UART after the mentioned statements above are processed I get the follwoing results (in Hex):

TCCR1A 00
TCCR1B 02
OCR1AH 00
OCR1AL 00
OCR1BH 00
OCR1BL 00
TIMSK1 00
TIFR1 07

According the processor manual the correct register settings should be:

'-----------------Prescaler 8
TCCR1B.CS12= 0
TCCR1B.CS11= 1
TCCR1B.CS11= 0
'---------------- Mode 3 PWM, Phase Correct, 10-bit
TCCR1B.WGM13=0
TCCR1B.WGM12=0
TCCR1A.WGM11=1
TCCR1A.WGM10=1
' ---------------- Compare Output mode
TCCR1A.COM1A1=1
TCCR1A.COM1B1=1
'------------------Duty preset
OCR1AH =0
OCR1AL =0x7D
OCR1BH = 0
OCR1BL = 0x7D

Working with this register settings the following commands are working properely

PWM16bit_Change_Duty(current_duty,_TIMER1_CH_A) resp.
PWM16bit_Change_Duty(current_duty1,_TIMER1_CH_B)

Is this a bug in PWM16 bit lib or is there an error on my side?
Any help is welcome.

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: PWM16bit_Init don't work w/ ATMEGA644P

#2 Post by slavisa.zlatanovic » 02 Jun 2011 14:00

Hi!

Sorry for the late response. This post somehow slipped our support eyes.
I'll check the issue you're talking about and get back to you later with results.
Best regards
Slavisa

Post Reply

Return to “mikroBasic PRO for AVR General”