Hello,
I’ve developed a motor control board using the PAC5524 microcontroller and to get started with understanding the SDK and how the microcontroller works, I’ve decided to control a DC brushed motor using an H bridge with the DRH4/DRL1 and DRH3/DRL0 pins.
To do this I used Timer A4 and TimerA5 using the motor control examples provided by qorvo for bldc control; however I only need to drive an H bridge for a simple DC motor just to start out.
The program isn’t generating PWM signals on the MOSFETs gates and I don’t know why.
I also programmed Timer C to blink an LED and its working fine, just the Timer A isn’t. Here’s the code for timer A init and the main function:
// Initialize the PWM signal for TAPWM4 (DRH4/DRL1) and TAPWM5 (DRH3/DRL0)
void pwm_init() {
// Set the PWM frequency for TAPWM4 and TAPWM5
const uint16_t period = 300000000/PWM_FREQUENCY; //300000000 - > clock 2 → divider 20000 → signal freq
// Configure Timer A Controls
pac5xxx_timer_clock_config(TimerA, TXCTL_CS_ACLK, TXCTL_PS_DIV1); // Configure timer clock input for ACLK, /1 divider
pac5xxx_timer_base_config(TimerA, period, AUTO_RELOAD, TxCTL_MODE_UP, TIMER_SLAVE_SYNC_DISABLE); // Configure timer frequency and count mode
// Configure Dead time generators
PAC55XX_TIMERA->CTL.DTGCLK = BEFORE_ACLK_DIVIDER; // 0--> The DTGCLK is the clock before the TACTL.CLKDIV clock divider.
// 1--> The DTGCLK is the clock after the TACTL.CLKDIV clock divider.
pac5xxx_dtg_config2(&(PAC55XX_TIMERA->DTGCTL0), RED_DEATH_TIMET, FED_DEATH_TIMET); // Configure DTGA0 for phase U
pac5xxx_dtg_config2(&(PAC55XX_TIMERA->DTGCTL1), RED_DEATH_TIMET, FED_DEATH_TIMET); // Configure DTGA1 for phase V
PAC55XX_TIMERA->CTL.MODE = TxCTL_MODE_UP;
PAC55XX_TIMERA->CCTR4.CTR = period >>2; // Set right PWM duty 25%
PAC55XX_TIMERA->CCTR5.CTR = period >>2; // Set right PWM duty 25%
PAC55XX_SCC->PBMUXSEL.P4 = 0x1; // 001b -> TAPWM4 - > family users guide pag- 127
PAC55XX_GPIOB->OUT.w = 0x04; //PORTB OUT GPIO = 0;
PAC55XX_SCC->PBMUXSEL.w = 0x01110111; //PORTB PSEL is ALL PWMs
//Configure PORTB Outputs to Push Pull
PAC55XX_GPIOB->MODE.w = 0x1515;
}
int main(void) {
// Disable global interrupts until initialization is complete
__disable_irq();
system_init();
// Initialize the PWM channels
pwm_init();
volatile int i;
configure_timer_c_compare_mode();
__enable_irq();
while(1){
// Add some delay between toggles
for(i=0; i < 500000; i++){
}
}
return 0;
}
Thank you