PIC32MX470F512H / PWM: Problem with setting the frequency

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
Speed64
Posts: 13
Joined: 19 Mar 2012 17:11
Location: Germany Barßel
Contact:

PIC32MX470F512H / PWM: Problem with setting the frequency

#1 Post by Speed64 » 14 Mar 2016 23:03

Problem with setting the frequency
I use the PIC32MX470F512H with 100Mhz
PWM with 16bit

pwm_period1 = PWM_Init(0, 1,0, 3)
for example current_duty = 1000
PWM_Start(1) PWM_Set_Duty(current_duty, 1)

I can not select a frequency

pwm_period1 = PWM_Init(5000, 1,0, 3)
pwm_period1 = PWM_Init(500, 1,0, 3)
pwm_period1 = PWM_Init(1000, 1,0, 3)
pwm_period1 = PWM_Init(100, 1,0, 3)

The frequency output remains at 1400 Hz PWM 16Bit
current duty is 0-65535

how can I adjust the frequency to 500Hz with 16 bit?

Sincerely Speed64

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: PIC32MX470F512H / PWM: Problem with setting the frequenc

#2 Post by Aleksandar.Mitrovic » 15 Mar 2016 15:22

Hi Speed64,

I suggest you to take a look at our example for PWM from the compiler, and customize it to your needs:
...\Mikroelektronika\mikroBasic PRO for PIC32\Examples\Internal MCU modules\PIC32MX460F512L\PWM

Also, to the Help file for the PWM library to see exactly what parameters do you need to set and what are their values.
"PWM frequency in Hz (refer to device datasheet for correct values in respect with Fosc)"

Kind regards,
Aleksandar

Post Reply

Return to “mikroBasic PRO for PIC32 General”