Determine the values of PSC, CCR, and ARR registers to generate the signal below if timer clock is 80 MHz.
T = 100us
W = 70us
First, we need to calculate the period in clock cycles for T and W:
T = 100us = 0.0001s
W = 70us = 0.00007s
Timer clock = 80 MHz = 80,000,000 Hz
Period in clock cycles:
T_cycles = T * Timer clock = 0.0001s * 80,000,000 = 8,000 cycles
W_cycles = W * Timer clock = 0.00007s * 80,000,000 = 5,600 cycles
Next, we need to find the values of the PSC, CCR, and ARR registers. The formula to calculate the PWM frequency is:
PWM frequency = Timer clock / (PSC * ARR)
Given that the PWM frequency is 10 kHz (100us period), we can rearrange the formula to solve for PSC and ARR:
PSC * ARR = Timer clock / PWM frequency = 80,000,000 / 10,000 = 8,000
One possible configuration is:
PSC = 1
ARR = 8000
Now we can calculate the CCR value for the pulse width of 70us:
CCR = T_cycles (W_cycles or 5600 if W is used) / T_cycles = 5600 / 8000 = 0.7
Therefore, the values of the registers would be:
PSC = 1
CCR = 0.7
ARR = 8000
are you sure this is correct?
I apologize for the earlier mistake in the calculation. Let's correct that and find the correct values for PSC, CCR, and ARR registers.
Given:
Timer clock = 80 MHz = 80,000,000 Hz
T = 100us = 0.0001s
W = 70us = 0.00007s
First, calculate the period in clock cycles for T and W:
T_cycles = T * Timer clock = 0.0001s * 80,000,000 = 8,000 cycles
W_cycles = W * Timer clock = 0.00007s * 80,000,000 = 5,600 cycles
Next, calculate the values of PSC and ARR registers:
Desired PWM frequency = 1 / T = 1 / 0.0001 = 10 kHz
PSC * ARR = Timer clock / Desired PWM frequency
PSC * ARR = 80,000,000 / 10,000 = 8000
To find suitable values, we can try different combinations keeping in mind that PSC*ARR should equal 8000.
One possible configuration is:
PSC = 79
ARR = 101
Finally, calculate the CCR value for the pulse width of 70us:
CCR = W_cycles / T_cycles = 5,600 / 8,000 = 0.7
So, the corrected values of the registers would be:
PSC = 79
CCR = 0.7
ARR = 101
These values should generate the desired signal with a period of 100us and a pulse width of 70us using an 80 MHz timer clock.