kopia lustrzana https://github.com/OpenRTX/OpenRTX
Doubled the prescale value of all the timers, since they run at twice the frequency of the bus they are connected to
rodzic
01ee477b02
commit
85a89d1f84
|
@ -101,7 +101,8 @@ void toneGen_init()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Timer configuration:
|
* Timer configuration:
|
||||||
* - APB1 frequency = 42MHz, with 1:10 prescaler we have Ftick = 4.2MHz
|
* - APB1 frequency = 42MHz but timer run at twice of this frequency: with
|
||||||
|
* 1:20 prescaler we have Ftick = 4.2MHz
|
||||||
* - ARR = 255 (8-bit PWM), gives an update rate of 16.406kHz
|
* - ARR = 255 (8-bit PWM), gives an update rate of 16.406kHz
|
||||||
* - Nominal update rate is 16.384kHz -> error = +22.25Hz
|
* - Nominal update rate is 16.384kHz -> error = +22.25Hz
|
||||||
*/
|
*/
|
||||||
|
@ -109,7 +110,7 @@ void toneGen_init()
|
||||||
__DSB();
|
__DSB();
|
||||||
|
|
||||||
TIM3->ARR = 0xFF;
|
TIM3->ARR = 0xFF;
|
||||||
TIM3->PSC = 9;
|
TIM3->PSC = 19;
|
||||||
TIM3->CCMR1 = TIM_CCMR1_OC2M_2 /* CH2 in PWM mode 1, preload enabled */
|
TIM3->CCMR1 = TIM_CCMR1_OC2M_2 /* CH2 in PWM mode 1, preload enabled */
|
||||||
| TIM_CCMR1_OC2M_1
|
| TIM_CCMR1_OC2M_1
|
||||||
| TIM_CCMR1_OC2PE;
|
| TIM_CCMR1_OC2PE;
|
||||||
|
|
|
@ -46,8 +46,9 @@ void platform_init()
|
||||||
adc1_init();
|
adc1_init();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure TIM8 for backlight PWM: Fpwm = 100kHz, 8 bit of resolution
|
* Configure TIM8 for backlight PWM: Fpwm = 100kHz with 8 bit of resolution.
|
||||||
* APB2 freq. is 84MHz, then: PSC = 327 to have Ftick = 256.097kHz
|
* APB2 freq. is 84MHz, but timer runs at twice this frequency.
|
||||||
|
* Then: PSC = 655 to have Ftick = 256.097kHz
|
||||||
* With ARR = 256, Fpwm is 100kHz;
|
* With ARR = 256, Fpwm is 100kHz;
|
||||||
* Backlight pin is connected to TIM8 CR1.
|
* Backlight pin is connected to TIM8 CR1.
|
||||||
*/
|
*/
|
||||||
|
@ -55,7 +56,7 @@ void platform_init()
|
||||||
__DSB();
|
__DSB();
|
||||||
|
|
||||||
TIM8->ARR = 255;
|
TIM8->ARR = 255;
|
||||||
TIM8->PSC = 327;
|
TIM8->PSC = 654;
|
||||||
TIM8->CNT = 0;
|
TIM8->CNT = 0;
|
||||||
TIM8->CR1 |= TIM_CR1_ARPE; /* LCD backlight is on PC6, TIM8-CH1 */
|
TIM8->CR1 |= TIM_CR1_ARPE; /* LCD backlight is on PC6, TIM8-CH1 */
|
||||||
TIM8->CCMR1 |= TIM_CCMR1_OC1M_2
|
TIM8->CCMR1 |= TIM_CCMR1_OC1M_2
|
||||||
|
|
|
@ -46,8 +46,9 @@ void platform_init()
|
||||||
adc1_init();
|
adc1_init();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Configure TIM8 for backlight PWM: Fpwm = 100kHz, 8 bit of resolution
|
* Configure TIM8 for backlight PWM: Fpwm = 100kHz with 8 bit of resolution.
|
||||||
* APB2 freq. is 84MHz, then: PSC = 327 to have Ftick = 256.097kHz
|
* APB2 freq. is 84MHz, but timer runs at twice this frequency.
|
||||||
|
* Then: PSC = 655 to have Ftick = 256.097kHz
|
||||||
* With ARR = 256, Fpwm is 100kHz;
|
* With ARR = 256, Fpwm is 100kHz;
|
||||||
* Backlight pin is connected to TIM8 CR1.
|
* Backlight pin is connected to TIM8 CR1.
|
||||||
*/
|
*/
|
||||||
|
@ -55,7 +56,7 @@ void platform_init()
|
||||||
__DSB();
|
__DSB();
|
||||||
|
|
||||||
TIM8->ARR = 255;
|
TIM8->ARR = 255;
|
||||||
TIM8->PSC = 327;
|
TIM8->PSC = 654;
|
||||||
TIM8->CNT = 0;
|
TIM8->CNT = 0;
|
||||||
TIM8->CR1 |= TIM_CR1_ARPE; /* LCD backlight is on PC6, TIM8-CH1 */
|
TIM8->CR1 |= TIM_CR1_ARPE; /* LCD backlight is on PC6, TIM8-CH1 */
|
||||||
TIM8->CCMR1 |= TIM_CCMR1_OC1M_2
|
TIM8->CCMR1 |= TIM_CCMR1_OC1M_2
|
||||||
|
|
|
@ -67,15 +67,16 @@ void platform_init()
|
||||||
|
|
||||||
#ifdef ENABLE_BKLIGHT_DIMMING
|
#ifdef ENABLE_BKLIGHT_DIMMING
|
||||||
/*
|
/*
|
||||||
* Configure TIM11 for backlight PWM: Fpwm = 256Hz, 8 bit of resolution
|
* Configure TIM11 for backlight PWM: Fpwm = 256Hz, 8 bit of resolution.
|
||||||
* APB2 freq. is 84MHz, then: PSC = 1281 to have Ftick = 65.52kHz
|
* APB2 freq. is 84MHz but timer runs at twice this frequency, then:
|
||||||
|
* PSC = 2564 to have Ftick = 65.52kHz
|
||||||
* With ARR = 256, Fpwm is 256Hz;
|
* With ARR = 256, Fpwm is 256Hz;
|
||||||
*/
|
*/
|
||||||
RCC->APB2ENR |= RCC_APB2ENR_TIM11EN;
|
RCC->APB2ENR |= RCC_APB2ENR_TIM11EN;
|
||||||
__DSB();
|
__DSB();
|
||||||
|
|
||||||
TIM11->ARR = 255;
|
TIM11->ARR = 255;
|
||||||
TIM11->PSC = 1282;
|
TIM11->PSC = 2563;
|
||||||
TIM11->CNT = 0;
|
TIM11->CNT = 0;
|
||||||
TIM11->CR1 |= TIM_CR1_ARPE;
|
TIM11->CR1 |= TIM_CR1_ARPE;
|
||||||
TIM11->CCMR1 |= TIM_CCMR1_OC1M_2
|
TIM11->CCMR1 |= TIM_CCMR1_OC1M_2
|
||||||
|
|
Ładowanie…
Reference in New Issue