cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with TIM1 configuration of STM32F303CD

MSeib
Associate

Hi,

I want to configure my TIM1 to use it for driving a bldc motor.

I have made several configuration in the registers, but it won't work.

     TIM1_CR1bits.CEN = 0;   //Timer enable
     TIM1_CR1bits.DIR_= 0;
     TIM1_CR1bits.CMS = 0b01;
     TIM1_CR1bits.CKD = 0b01;
     TIM1_CR1bits.ARPE = 0;  //Auto-reload preload enable
     TIM1_CCMR1_Outputbits.OC1PE = 1;
     TIM1_CCMR1_Outputbits.OC2PE = 1;
     TIM1_CCMR2_Outputbits.OC3PE = 1;
     TIM1_CCMR1_Outputbits.OC1M = 0b0110;
     TIM1_CCMR1_Outputbits.OC2M = 0b0110;
     TIM1_CCMR2_Outputbits.OC3M = 0b0110;
     TIM1_CCERbits.CC1E = 0;
     TIM1_CCERbits.CC2E = 0;
     TIM1_CCERbits.CC3E = 0;
     TIM1_CCERbits.CC1NE = 0;
     TIM1_CCERbits.CC2NE = 0;
     TIM1_CCERbits.CC3NE = 0;
     TIM1_CCERbits.CC1P = 0;
     TIM1_CCERbits.CC2P = 0;
     TIM1_CCERbits.CC3P = 0;
     TIM1_CCERbits.CC1NP = 1;
     TIM1_CCERbits.CC2NP = 1;
     TIM1_CCERbits.CC3NP = 1;
     TIM1_CR2bits.OIS1 = 0;
     TIM1_CR2bits.OIS2 = 0;
     TIM1_CR2bits.OIS3 = 0;
     TIM1_CR2bits.OIS1N = 0;
     TIM1_CR2bits.OIS2N = 0;
     TIM1_CR2bits.OIS3N = 0;
     TIM1_CCMR1_Outputbits.OC1FE = 0;
     TIM1_CCMR1_Outputbits.OC2FE = 0;
     TIM1_CCMR2_Outputbits.OC3FE = 0;
     
     TIM1_BDTRbits.OSSR = 1;
     TIM1_BDTRbits.OSSI = 1;
     TIM1_BDTRbits.LOCK = 0b01;
     TIM1_BDTRbits.DTG = BLDC_deadTime;
     TIM1_BDTRbits.BKE = 1;
     TIM1_BDTRbits.BKP = 1;
     TIM1_BDTRbits.BKF = 0;
     TIM1_BDTRbits.BK2E = 1,
     TIM1_BDTRbits.BK2P = 1;
     TIM1_BDTRbits.BK2F = 0;
     TIM1_BDTRbits.AOE = 0;
     TIM1_BDTRbits.MOE = 0;
     NVIC_IntEnable(IVT_INT_TIM1_UP_TIM16);
     TIM1_CR1bits.CEN  = 1;

One problem is, that the interrupt doesn't work any more and the second one is that the pwm is not generated.

In another function i set the duty in the ccr register.

The third problem is, that with block commutation i have to switch off one channel per step.

but i couldn't find a way that this is happening. Allways the positive channel was low but the negative channel was high. This one should be also low.

Maybe someone can help me.

Best regards Max

0 REPLIES 0