PWM program from mikroC PRO for PIC Help

Post your requests and ideas for the mikroElektronika website & forums.
Author
Message
Radu86
Posts: 47
Joined: 11 Jan 2010 17:10
Location: Romania, Iasi

Re: PWM program from mikroC PRO for PIC Help

#16 Post by Radu86 » 24 Feb 2011 23:11

Well, we do not know what's the code in mE's library. I believe it set's the OSC so you don't have to. But I am not sure.
PWM1_init initializez the first module. I don't know how many modules does your pic have. You should check the datasheet for that.

Ideacharge
Posts: 16
Joined: 26 Dec 2010 16:47

Re: PWM program from mikroC PRO for PIC Help

#17 Post by Ideacharge » 24 Feb 2011 23:19

Maybe could be a bad PIC configuration settings?

masab_ahad
Posts: 2
Joined: 25 Dec 2011 09:50

Re: PWM program from mikroC PRO for PIC Help

#18 Post by masab_ahad » 25 Dec 2011 10:28

did the program work in proteus? i have also checked some simple examples in proteus but they aren't working too....

00100
Posts: 1
Joined: 01 May 2012 17:54

Re: PWM program from mikroC PRO for PIC Help

#19 Post by 00100 » 01 May 2012 18:00

Hey;
Why does'nt this program work ?
Why nobody answer us ?

aparna k
Posts: 55
Joined: 17 Jul 2019 07:17

Re: PWM program from mikroC PRO for PIC Help

#20 Post by aparna k » 10 Oct 2019 08:51

Hi
I am using PIC18F67K40. In this, I am implementing PMW. But it is not working. Can you suggest me what is the issue?

User avatar
stefan.filipovic
mikroElektronika team
Posts: 1135
Joined: 18 Dec 2018 10:30

Re: PWM program from mikroC PRO for PIC Help

#21 Post by stefan.filipovic » 15 Oct 2019 11:03

Hi,

Please find the simple example for PWM with PIC18F67K40 in the attachment.

Kind regards,
Attachments
PWM.ZIP
(87.99 KiB) Downloaded 141 times
Stefan Filipović

aparna k
Posts: 55
Joined: 17 Jul 2019 07:17

Re: PWM program from mikroC PRO for PIC Help

#22 Post by aparna k » 15 Oct 2019 12:00

Thanks for your reply.
Already I got the functionality of PWM. But I want to decrease PWM frequency. The least possible frequency is 489Hz. If I give less than this frequency, it is giving an error. Can I decrease that frequency? If it is possible, then how to decrease? Please suggest to me.

User avatar
stefan.filipovic
mikroElektronika team
Posts: 1135
Joined: 18 Dec 2018 10:30

Re: PWM program from mikroC PRO for PIC Help

#23 Post by stefan.filipovic » 16 Oct 2019 13:35

Hi,

The PWM frequency is derived from the system clock frequency, so I guess you are using 64 MHz Fosc, with this Fosc you can't get PWM frequency lower than 489Hz. Decreasing the Fosc frequency you will be able to decrease the PWM frequency.

Kind regards,
Stefan Filipović

mmm
Posts: 38
Joined: 28 Apr 2019 18:25

Re: PWM program from mikroC PRO for PIC Help

#24 Post by mmm » 08 Dec 2020 11:30

Hello,
I am using PIC18F67K40 MCU, I need to generate the PWM signal but my problem is I new to PPS config settings so I found one example code and generate the pwm signal but every 2 sec it will generate the PWM signal its width is changing very lately so please help me to get the perfect pwm signal as our requirement.

Code:
unsigned int duty1 = 0;

void InitMain() {
OSCCON1 = 0X60; //HFINTOSC & 1:1 Divider
OSCCON3 = 0x00; // inorder to decrease the clock rate i used OSCCON2
OSCTUNE = 0x00; //mAximum Frequency
OSCFRQ = 0X08; //64 Mhz
TRISC.B4 = 0; // designate PORTC pins as output
PORTC.B4 = 0; // set PORTC to 0


Unlock_IOLOCK();
PPS_Mapping_NoLock(_RC4, _OUTPUT, _CCP1);
Lock_IOLOCK();

PWM1_Remappable_Init(5000); // Initialize PWM1 module at 5KHz

}

void main() {
InitMain();
PWM1_Remappable_Start(); // start PWM1
while(1){

for(duty1 = 0; duty1 < 90; duty1++){
PWM1_Remappable_Set_Duty(duty1);
Delay_us(1);
}
for(duty1 = 60; duty1 > 0; duty1--){
PWM1_Remappable_Set_Duty(duty1);
Delay_us(1);
}
}
}

please guide me, thanks in advance,

best regards
mmm

Post Reply

Return to “Website & Forums Wishlist”