Hi every body,
i am now in programming dsPIC using dsPIC, and i try to program a PWMs in the aim to control an inverter using dsPIC 33fj128mc706. I use mikroC_dsPIC and i have this simple program :
void main()
{
PWM1_Init(5000, 0, 1, 0); // Init Pwm1 at 5 kHz
PWM2_Init(5000, 0, 2, 0); // Init Pwm2 at 5 kHz
PWM3_Init(5000, 0, 3, 0); // Init Pwm3 at 5 kHz
PWM1_Start();
PWM2_Start();
PWM3_Start();
while(1)
{
PWM1_Set_Duty(128);
PWM2_Set_Duty(128);
PWM3_Set_Duty(128);
Delay_ms(1000);
}
}
But i have some error like
';' expected but )
Thanks a lot for your help
How to program a PWMs using mikroC dsPIC
- dejan.odabasic
- mikroElektronika team
- Posts: 2649
- Joined: 30 Apr 2012 14:20
Re: How to program a PWMs using mikroC dsPIC
Hello,
could you tell me what is the version of your compiler?
Best regards.
could you tell me what is the version of your compiler?
Best regards.
-
- Posts: 58
- Joined: 31 May 2012 19:27
Re: How to program a PWMs using mikroC dsPIC
Thank you for reply,dejan.odabasic wrote:Hello,
could you tell me what is the version of your compiler?
Best regards.
i use MikroC : mikroc.dspic.v4.0.0.0 version
- dejan.odabasic
- mikroElektronika team
- Posts: 2649
- Joined: 30 Apr 2012 14:20
Re: How to program a PWMs using mikroC dsPIC
Hello,
I suggest you to download and install the latest version (MikroC PRO for dsPIC 5.6)
http://www.mikroe.com/eng/products/view ... for-dspic/
Our PRO line of compilers came out about four years ago.
I could help you with some examples, but I'm using latest version compiler, and many of the old libraries and their functions are drastically changed.
Please try to rewrite your example using new compiler and let me know if you had any success.
Best regards.
I suggest you to download and install the latest version (MikroC PRO for dsPIC 5.6)
http://www.mikroe.com/eng/products/view ... for-dspic/
Our PRO line of compilers came out about four years ago.
I could help you with some examples, but I'm using latest version compiler, and many of the old libraries and their functions are drastically changed.
Please try to rewrite your example using new compiler and let me know if you had any success.
Best regards.
-
- Posts: 58
- Joined: 31 May 2012 19:27
Re: How to program a PWMs using mikroC dsPIC
Thank you for reply and for the link.dejan.odabasic wrote:Hello,
I suggest you to download and install the latest version (MikroC PRO for dsPIC 5.6)
http://www.mikroe.com/eng/products/view ... for-dspic/
Our PRO line of compilers came out about four years ago.
I could help you with some examples, but I'm using latest version compiler, and many of the old libraries and their functions are drastically changed.
Please try to rewrite your example using new compiler and let me know if you had any success.
Best regards.
I have goot now a last version of MikroC, and i have written the following project:
unsigned int current_duty, adcRes;
unsigned int pwm_period1;
void main() {
PORTB = 0x0000; // set pin as output
TRISB.F0 = 1; // set pin as input - needed for ADC to work (for ADC1BUF0)
ADC1_Init();
current_duty = 25; // initial value for current_duty
pwm_period1 = PWM_Init(5000, 1, 1, 0);
PWM_Start(1); // Star PWM module 1
while (1) { // endless loop
adcRes = ADC1_Get_Sample(1); // read the new value of ADC
PWM_Set_Duty(adcRes, 1); // set newly acquired duty ratio by the value which is given by ADC
Delay_ms(20);
}
}
I want to know if this project works well.
Best reagrds
-
- Posts: 58
- Joined: 31 May 2012 19:27
Re: How to program a PWMs using mikroC dsPIC
Hi every body,
i have succefuly configure ADC and PWM using a last version of MikroC PRO. Now, my question is about how to configure a 3 PWM (with phase shift). Note that my frequency is 60 Hz.
Thank you
i have succefuly configure ADC and PWM using a last version of MikroC PRO. Now, my question is about how to configure a 3 PWM (with phase shift). Note that my frequency is 60 Hz.
Thank you
- dejan.odabasic
- mikroElektronika team
- Posts: 2649
- Joined: 30 Apr 2012 14:20
Re: How to program a PWMs using mikroC dsPIC
Hello,
unfortunately phase shifting features are not supported by our library at this moment.
I will pass your interest, related to the phase shift, to our software development team.
Best regards.
unfortunately phase shifting features are not supported by our library at this moment.
I will pass your interest, related to the phase shift, to our software development team.
Best regards.
-
- Posts: 58
- Joined: 31 May 2012 19:27
Re: How to program a PWMs using mikroC dsPIC
Thank you for your response and your interest for my research works. I await your developments with impatience.dejan.odabasic wrote:Hello,
unfortunately phase shifting features are not supported by our library at this moment.
I will pass your interest, related to the phase shift, to our software development team.
Best regards.
Best regards