I really just want to have A1 and B3 identical.
Can somebody point me to some example or documentation?
My code is below, there are probably some unnecessary things because I've been testing all kind of things (for example cr2 as 0x2001 is only a test).
Code: Select all
Pins[16].function(PIN_16_PWM_B3);
Pins[15].function(PIN_15_PWM_A1);
sim1.mcpwm.sm[1].cr1 = 0x0404;
sim1.mcpwm.sm[1].cr2 = 0x2000;
sim1.mcpwm.sm[1].init = 0;
sim1.mcpwm.sm[1].val[0] = 2500;
sim1.mcpwm.sm[1].val[1] = 5000;
sim1.mcpwm.sm[1].val[2] = 0; // PWM A ON counter value
sim1.mcpwm.sm[1].val[3] = 8; // PWM A OFF counter value
sim1.mcpwm.sm[1].val[4] = 8; // PWM B ON counter value
sim1.mcpwm.sm[1].val[5] = 0; // PWM B OFF counter value
sim1.mcpwm.sm[1].ocr = 0;
sim1.mcpwm.sm[1].dismap=0xFF00;
sim1.mcpwm.sm[3].cr1 = 0x0444;
sim1.mcpwm.sm[3].cr2 = 0x2001;//0x2001;// &= 0x2000;
sim1.mcpwm.sm[3].init = 0;
sim1.mcpwm.sm[3].val[0] = 2500;
sim1.mcpwm.sm[3].val[1] = 5000;
sim1.mcpwm.sm[3].val[2] = 0;
sim1.mcpwm.sm[3].val[3] = 8;
sim1.mcpwm.sm[3].val[4] = 8;
sim1.mcpwm.sm[3].val[5] = 0;
sim1.mcpwm.sm[3].ocr = 0;
sim1.mcpwm.sm[3].dismap=0xFF00;
//Set output mask to 0
sim1.mcpwm.mask = 0;
sim1.mcpwm.outen |= 0x0080;// Enable PWM B3
sim1.mcpwm.outen |= 0x0200; // Enable PWM A1
if(sim1.mcpwm.mcr & 0x000F == 0x000F){
sim1.mcpwm.mcr |= 0x00F0;
}
//Once cleared, clear the reset bit to enable LDOK to run later.
sim1.mcpwm.mcr &= 0xFF0F;