Use an oscilloscope to measure duty cycles. Suppose the default MSI clock is use
ID: 2082940 • Letter: U
Question
Use an oscilloscope to measure duty cycles. Suppose the default MSI clock is used, which is 2.097 MHz.
What is the relationship between the system clock, the counter clock CK_CNT, and prescaler TIM4_PSC, and the pulse period measured?
We want to keep TIM4_ARR fixed, but set TIM4_CCR1 to three different values, as listed below. How would you set up ARR, PSC, and CCR register values?
Calculate the dy measured and verified the correctness.
Case 1: TIM4_CCR1 = 1/6 * (TIM4_ARR + 1)
Case 2: TIM4_CCR1 = 1/3 * (TIM4_ARR + 1)
Case 3: TIM4_CCR1 = 1/2 * (TIM4_ARR + 1)
Case
TIM4_CCR1
Pulse Width
Pulse Period
#1
#2
#3
Case
TIM4_CCR1
Pulse Width
Pulse Period
#1
#2
#3
Explanation / Answer
he PIC32 is equipped with 5 16-bit timers (Timer1, Timer2, Timer3, Timer4, and Timer5). A timer increments based on a clock signal, which may come from an internal source (the peripheral bus clock, 80 MHz for us) or an external source (such as an encoder). Each timer x has an associated pin TxCK for the external source. In addition, a prescaler determines how many clock pulses must be received before the counter increments. If the prescaler is set to 1:1, the counter increments on each clock pulse; if it is set to 1:4, it increments every fourth pulse. Both the clock source type (internal and external) and the prescaler value are set in software.
Each 16-bit timer can count from 0 to 2^16 - 1 = 65535 = 0xFFFF, at which point it "rolls over" to 0 again. The timer can also be made to roll over at any count less than 0xFFFF by setting the period of the timer roll-over in software. We can also configure the timer to generate an interrupt when this roll-over event occurs. In this way, by using the peripheral bus clock as the clock source, we can generate precisely timed events, such as the execution of a control law in feedback control.
These features are common to each of the timers. However, we can separate the timers into two types: Type A and Type B. Added features of each type of timer are indicated below
Details
The functions of the timers are controlled by special function registers (SFRs). Each of these SFRs has 32 bits on the PIC32, but for many, not all of the bits are relevant. Depending on whether these bits are 0 or 1, different actions or settings are performed for Timer x:
Counter interrupts are controlled with the following SFRs:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.