Hi all,
For my application I'm using several synchronized ePWM channels, with a fairly lengthy initialization process to ensure that the output signals are perfect without any odd behavior during the first couple periods. I follow TI's advice by holding TBCLKSYNC = 0 while doing initializing all the registers, then write TBCLKSYNC = 1 to activate the ePWM operation (followed by a software force sync). However, I've noticed some things in the initialization routine don't work the way I expect. For example, I want to set the initialize the states of the PWM outputs by initializing the AQ module. Here's roughly how I try to do this:
// Disable TBCLKSYNC EALLOW; CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0; EDIS; .... //init the AQ so that both pins are initially low //ePWMB is inverted in DB module, so need to set B output HIGH EPwm1Regs.AQSFRC.bit.RLDCSF=3; //set for immediate reload EPwm1Regs.AQSFRC.bit.ACTSFA=AQ_CLEAR; EPwm1Regs.AQSFRC.bit.ACTSFB=AQ_SET; //assert a one-time force EPwm1Regs.AQSFRC.bit.OTSFA=1; EPwm1Regs.AQSFRC.bit.OTSFB=1; .... // set up DB to invert B output of AQ EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; //This is where I observe my B pin going high. ... // register initialization is done // enable timebase clock EALLOW; CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1; __asm (" nop"); __asm (" nop"); __asm (" nop"); __asm (" nop"); __asm (" nop"); //Perform a software sync EPwm1Regs.TBCTL.bit.SWFSYNC = 1; //force all timebases to load from TBPHS __asm (" nop"); __asm (" nop"); __asm (" nop"); __asm (" nop"); __asm (" nop"); EDIS;
However, the OTSFA operations don't seem to do anything. But I do see the ePWM1B pin go high when DBCTL.bit.POLSEL is written. In the debugger, it seems that if I manually set TBCLKSYNC any time after that, then ePWM1B goes low immediately, almost as if the OTSF operation was kept pending until then.
So what operations actually take effect when TBCLKSYNC = 0, and which ones will wait for TBCLKSYNC to be set = 1?