Doubled the prescale value of all the timers, since they run at twice the frequency of the bus they are connected to

replace/c683841f7846604232995f057c75254400cc8844
Silvano Seva 2020-11-16 18:03:02 +01:00
rodzic 01ee477b02
commit 85a89d1f84
4 zmienionych plików z 15 dodań i 11 usunięć

Wyświetl plik

@ -101,7 +101,8 @@ void toneGen_init()
/*
* 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
* - Nominal update rate is 16.384kHz -> error = +22.25Hz
*/
@ -109,7 +110,7 @@ void toneGen_init()
__DSB();
TIM3->ARR = 0xFF;
TIM3->PSC = 9;
TIM3->PSC = 19;
TIM3->CCMR1 = TIM_CCMR1_OC2M_2 /* CH2 in PWM mode 1, preload enabled */
| TIM_CCMR1_OC2M_1
| TIM_CCMR1_OC2PE;

Wyświetl plik

@ -46,8 +46,9 @@ void platform_init()
adc1_init();
/*
* Configure TIM8 for backlight PWM: Fpwm = 100kHz, 8 bit of resolution
* APB2 freq. is 84MHz, then: PSC = 327 to have Ftick = 256.097kHz
* Configure TIM8 for backlight PWM: Fpwm = 100kHz with 8 bit of resolution.
* 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;
* Backlight pin is connected to TIM8 CR1.
*/
@ -55,7 +56,7 @@ void platform_init()
__DSB();
TIM8->ARR = 255;
TIM8->PSC = 327;
TIM8->PSC = 654;
TIM8->CNT = 0;
TIM8->CR1 |= TIM_CR1_ARPE; /* LCD backlight is on PC6, TIM8-CH1 */
TIM8->CCMR1 |= TIM_CCMR1_OC1M_2

Wyświetl plik

@ -46,8 +46,9 @@ void platform_init()
adc1_init();
/*
* Configure TIM8 for backlight PWM: Fpwm = 100kHz, 8 bit of resolution
* APB2 freq. is 84MHz, then: PSC = 327 to have Ftick = 256.097kHz
* Configure TIM8 for backlight PWM: Fpwm = 100kHz with 8 bit of resolution.
* 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;
* Backlight pin is connected to TIM8 CR1.
*/
@ -55,7 +56,7 @@ void platform_init()
__DSB();
TIM8->ARR = 255;
TIM8->PSC = 327;
TIM8->PSC = 654;
TIM8->CNT = 0;
TIM8->CR1 |= TIM_CR1_ARPE; /* LCD backlight is on PC6, TIM8-CH1 */
TIM8->CCMR1 |= TIM_CCMR1_OC1M_2

Wyświetl plik

@ -67,15 +67,16 @@ void platform_init()
#ifdef ENABLE_BKLIGHT_DIMMING
/*
* Configure TIM11 for backlight PWM: Fpwm = 256Hz, 8 bit of resolution
* APB2 freq. is 84MHz, then: PSC = 1281 to have Ftick = 65.52kHz
* Configure TIM11 for backlight PWM: Fpwm = 256Hz, 8 bit of resolution.
* 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;
*/
RCC->APB2ENR |= RCC_APB2ENR_TIM11EN;
__DSB();
TIM11->ARR = 255;
TIM11->PSC = 1282;
TIM11->PSC = 2563;
TIM11->CNT = 0;
TIM11->CR1 |= TIM_CR1_ARPE;
TIM11->CCMR1 |= TIM_CCMR1_OC1M_2