I just can't get the PWM working. Trying to use PTB3 and PTB2 to drive two separate heaters. The frequency should be 10k. The duty cycle is set to be about 50%. Below is the function that I developed to set it up. What am I missing? I plugged PTB3 into an oscilloscope, and it was a flat line. The oscilloscope is definitely working. Thanks a lot.
void PWM_setup(
SIM_SCGC5 |= SIM_SCGC5_PORTB_MASK;
SIM_SCGC6 |= (1<<26);
SIM_SOPT2 |= (1<<24); /* Select main clock source for the TPM module */
TPM2_SC = (000001011);
TPM2_CONF |= 0xC0;
PORTB_PCR3 = PORT_PCR_MUX(3);
PORTB_PCR2 = PORT_PCR_MUX(3);
TPM2_CNT = 111; //Causes CNT to start counting.
TPM2_MOD = (1001011000); //PWM period
TPM2_C0V = 101011000; //Duty cycle
TPM2_C1V = 101011000;
TPM2_C0SC = 00101100;
TPM2_C1SC = 00101100;
}
EDIT: The problem was that I was writing an int into the register, not a binary. Embarrassing, but I'll leave this up as an example of how to set up PWM.