HI,
Using Code warrior special edition
version 5.7.0
Build 1932
Full chip simulation but i intend to use a HC12 (S12DP512)
Im currently trying to configure PWM channels to work with 16 bits
From the .pdf file i found:
"The PWMCTL register contains four control bits, each of which is used to concatenate a pair of PWM channels into one 16-bit channel."
Here is my code
Code:
void setupPWM(void){ PWMPOL = 170; /* outputs are high at the beginning of the period, then go low when the duty count is reached. */ PWMCAE = 0; /* operate in left aligned output mode. */ PWMCLK = 0; /* Clock B is the clock source for PWM channel 7 and 3, Clock A is the clock source for PWM channel 1and 5. */ PWMPRCLK = 0; /* Clock A = Clock B = Bus Clock */ PWMCTL = 255; /* Channel 0-1 , 2-3 , 4-5 , 6-7 concatenated */ PWMSDN = 0; /* Disable Emergency shutdown */ PWMPER01 = 8000; /* setup for PERIOD */ PWMDTY01 = 4000; /* setup for DUTY CYCLE */ PWME = 255; /* Enable PWM function on Port P for all channel */}void main(void){ setupPWM(); EnableInterrupts; for(;;){ }}
Then im using the true-time simulator
with a LED as the visualisation for the adress 0x258 of the PTP byte
and i have no reaction
The documentation mentionned to set PWMPERx > PWMDTYx
which i did
then i tried this ( these examples are for a duty cycle around 50%)
Code:
PWMPER01 = 8000;PWMDTY01 = 3841;
and with this the LED is working properly
I think the simulator does a comparison between each 8 bits PWMPER1 and PWMDTY1 or PWMPER0 and PWMDTY0 to check the condition "PWMPERx > PWMDTYx"
well can someone help me