Different duty cycle on dsPIC30 PWM1L and PWM1H

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
nikyc
Posts: 5
Joined: 24 Apr 2011 09:15
Location: Sibiu, Romania

Different duty cycle on dsPIC30 PWM1L and PWM1H

#1 Post by nikyc » 25 Apr 2011 07:59

Hello,

I'm using a dsPIC30F3011 and I need to obtain a different duty cycle on PWM1L and PWM1H with both channels working at the same frequency ( 50Hz ). My code looks like this:

Code: Select all

void sinit(void) {

     PWM1_Mc_Init(50,1,0x11,15);
     PWM1_Mc_Start();

}

void sopen(void) {

     PWM1_Mc_Set_Duty(900,0);   // left - PWM1L - 0,9ms
     PWM1_Mc_Set_Duty(4400,1);  // right - PWM1H - 4,4ms

}

void sclose(void) {

     PWM1_Mc_Set_Duty(2900,0);   // left - PWM1L - 2,9ms
     PWM1_Mc_Set_Duty(2400,1);   // right - PWM1H - 2,4ms

}

void main() {

     sinit();
     
     while(1) {
     
          sopen();
          Delay_ms(2000);
          sclose();
          Delay_ms(2000);
     
     }

}
It is possible to get it working? Or I should use different PWM channels ( like PWM1L and PWM2L )?

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

Re: Different duty cycle on dsPIC30 PWM1L and PWM1H

#2 Post by slavisa.zlatanovic » 26 Apr 2011 10:01

Hi!

We strongly encourage users to switch to PRO version because non-PRO version is an ancestor of PRO compiler
and is no longer being developed.
Every new feature, improvement and bug fix will only affect new versions of PRO compilers.
If you're a registered user you'll receive PRO license key free of charge.
See the migration document for more details:
Migration_document.PNG
Migration_document.PNG (15.87 KiB) Viewed 2775 times
Best regards
Slavisa

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”