| Electronic Components Datasheet Search |
|
AN4157 Datasheet(PDF) 19 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN4157 Datasheet(HTML) 19 Page - STMicroelectronics |
|
19 / 24 page ![]() AN4157 Peripheral firmware examples description Doc ID 023629 Rev 1 19/24 3.22 TIM time base example 3.22.1 Purpose This example shows how to configure the TIM peripheral in Output Compare Timing mode with the corresponding Interrupt requests for each channel, in order to generate 2 different time bases. 3.22.2 Description TIM3CLK frequency is set SystemCoreClock, to obtain a TIM3 counter clockfrequency of 6 MHz. As a consequence, the prescaler is computed as follows: ● Prescaler = (TIM3CLK / TIM3 counter clock) - 1. ● SystemCoreClock is set to 72 MHz. ● The TIM3_CCR1 register value is equal to 40961, TIM3_CCR1 update rate = TIM3 counter clock / CCR1_Val = 1757.77 Hz. As a result, TIM3 Channel 1 generates an interrupt each 6.8ms. ● The TIM3_CCR2 register is equal to 27309, TIM3_CCR2 update rate = TIM3 counter clock / CCR2_Val = 2636.49 Hz. As a result, TIM3 Channel 2 generates an interrupt each 4.55ms. ● The TIM3_CCR3 register is equal to 13654, TIM3_CCR3 update rate = TIM3 counter clock / CCR3_Val = 5273.18 Hz. As a result, TIM3 Channel 3 generates an interrupt each 2.27ms ● The TIM3_CCR4 register is equal to 6826, TIM3_CCR4 update rate = TIM3 counter clock / CCR4_Val = 10547.9 Hz. As a result, TIM3 Channel 4 generates an interrupt each 1.13ms. When the counter value reaches the Output compare registers values, the Output Compare interrupts are generated and, in the handler routine, 4 leds (LED3, LED4, LED5 and LED6) are toggled at the following frequencies: ● LED3: 878.88 Hz (CC1) ● LED4: 1318.24Hz (CC2) ● LED5: 2636.59Hz (CC3) ● LED6: 5273.95Hz (CC4) Note: Use LED3, LED4, LED5 and LED6 connected respectively to PE8, PE9,PE10 and PE15 pins and connect them to an oscilloscope to show the different Time Base signals. |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |