Hi All,
I am using UCD3138, and I have to use TCAP pin to generate PWM signals(all of my other DPWM modules as well as PWM outputs are busy) to control a fan. At this point, I just want to make sure that I can generate some PWM signals using software on pin TCAP. As I am a hardware engineer, I am not so familiar with software.I came up with the following codes: Can you please let me know if it will be giving me PWM signals on TCAP? (Forget about the duty cycle and frequency at this point):
for(;;)
{
// Set pin TCAP to 1
MiscAnalogRegs.GLBIOEN.bit.TMR_CAP_IO_EN = 1; // enable TCAP as GPIO
MiscAnalogRegs.GLBIOOE.bit.TMR_CAP_IO_OE = 1; // make it output
MiscAnalogRegs.GLBIOVAL.bit.TMR_CAP_IO_VALUE = 1; // set output to high
// Set Timer3 to generate delay=duty cycle
TimerRegs.T16PWM3CMP0DAT.bit.CMP_DAT = 1587; // Value to reset the counter and specify duty cycle
TimerRegs.T16PWM3CMPCTRL.bit.CMP0_INT_ENA = 1; // interrupt when reset
TimerRegs.T16PWM3CNTCTRL.bit.CMP_RESET_ENA = 1; // enable reset by comp0
TimerRegs.T16PWM3CNTCTRL.bit.SW_RESET = 1; // allow counter to run
TimerRegs.T16PWM3CMPCTRL.all |= 3; // clear interrupt flag
// Set pin TCAP to 0
MiscAnalogRegs.GLBIOVAL.bit.TMR_CAP_IO_VALUE = 0; // set output to high
// Set Timer3 to generate delay=off-time
TimerRegs.T16PWM3CMP0DAT.bit.CMP_DAT = 1587; // Value to reset the counter and specify duty cycle
TimerRegs.T16PWM3CMPCTRL.bit.CMP0_INT_ENA = 1; // interrupt when reset
TimerRegs.T16PWM3CNTCTRL.bit.CMP_RESET_ENA = 1; // enable reset by comp0
TimerRegs.T16PWM3CNTCTRL.bit.SW_RESET = 1; // allow counter to run
TimerRegs.T16PWM3CMPCTRL.all |= 3; // clear interrupt flag
}
Thanks all in advance