PWM CONFIGURATION

nobody wrote on Sunday, January 21, 2007:

HI!!

Can you help us please with the following problem:

We made a PWM configuration (PIC18f452) to drive two motors using the CCP1CON and CCP2CON registers. It is the program code:

void Configuracion_PWM(void)
{
PR2=0xFF;
  
CCP1CONbits.DC1B1=DUTY_PWM1bits.BIT1;  
CCP1CONbits.DC1B0=DUTY_PWM1bits.BIT0; 
CCPR1L=DUTY_PWM1>>2;  // Config. duty cicle (MSB) PWM1
  
CCP2CONbits.DC2B1=DUTY_PWM2bits.BIT1;  
CCP2CONbits.DC2B0=DUTY_PWM2bits.BIT0;  
CCPR2L=DUTY_PWM2>>2;   // Config. duty cicle (MSB) PWM2
  
TRISCbits.TRISC2=0;    
TRISCbits.TRISC1=0;            
   
TRISBbits.TRISB4=0; 
TRISBbits.TRISB5=0;    
       
T2CONbits.TMR2ON=1;           
   
T2CONbits.T2CKPS1=1;
T2CONbits.T2CKPS0=1;  
   
     
CCP1CONbits.CCP1M3=1;
CCP1CONbits.CCP1M2=1;
CCP1CONbits.CCP1M1=0;
CCP1CONbits.CCP1M0=0;  
  
CCP2CONbits.CCP2M3=1;
CCP2CONbits.CCP2M2=1;
CCP2CONbits.CCP2M1=0;
CCP2CONbits.CCP2M0=0;  
}

This program works very well, but we have to put it into the FREERTOS, so the problem is that both of them are using the same register CCPCON1.

Thanks so much for your help. We´ll waiting your best answer.

Best Regards,

Moneditas

nobody wrote on Monday, January 22, 2007:

You can generate the tick interrupt from any peripheral that can generated a fix period interrupt.  I’m not familiar with the PIC, but other processors I have used have been able to generate the tick from the watchdog timer.  Look at the function prvSetupTimerInterrupt() in port.c for the PIC18 port.  This is where the timer interrupt is configured.  You can change it as required.