2020-01-17 10:26 PM
part number: STM32F779BI
I am using clock frequency 108 MHz ( not system clock , system clock is 216 MHZ)
I don't want to use loop
if not possible what is the maximum value i could set using timer
Solved! Go to Solution.
2020-01-19 11:24 PM
ok, I will configure , and let you know
2020-01-20 12:12 AM
I have updated my code, but still not working,
RCC->APB1ENR |= (1<<0); // Enable clok for timer 2
RCC->APB1ENR |= (1<<1); // Enable clok for timer 3
TIM2->PSC = uwPrescalerValue;
TIM3->PSC = uwPrescalerValue;
TIM2->EGR = TIM_EGR_UG;
TIM3->EGR = TIM_EGR_UG;
TIM2->CR2 |= TIM_CR2_MMS_1;
TIM2->SMCR |= TIM_SMCR_ETPS_0; // done
TIM3->SMCR |= TIM_SMCR_TS_0; // done
TIM3->SMCR |= TIM_SMCR_SMS_0 | TIM_SMCR_SMS_1 |TIM_SMCR_SMS_2; // done
TIM2->CR1 = TIM_CR1_CEN;
TIM3->CR1 = TIM_CR1_CEN;
2020-01-20 12:34 AM
Be more specific with "not working".
Read out and check the content of both TIMs' registers.
JW
2020-01-20 12:58 AM
2020-01-20 01:26 AM
You can see the prescaler and period (ARR) values for TIM2. Using these and the APB clock value, you can calculate the period of TIM2. Now multiply this period with the prescaler of TIM3. That's when the counter of TIM3 will be incremented by 1.
2020-01-20 01:38 AM
In other words, as TIM2 is 32-bit, if TIM2's input frequency is 54MHz, the first tick to TIM3 will come in cca 4'000'000 seconds, which is roughly one and a half month.
JW
2020-01-20 03:51 AM
I have follwing changed my code and used another TIM4 as master and same TIM3 as slave
APB1 Clock freqruency is=108MHz
TIM4->PSC=108
TIM3->PSC=1080
TIM4 & TIM3 both are 16 bit timer so ,ARR value is=65535 for both
so accoring to calculation i should get timer 3 will increment at ~71 sec by 1 but i am getting increment at ~143 sec
so what i am going wrong?
2020-01-20 03:52 AM
Such type of delays are a job for software timers. Software timers with callbacks are absolute necessity for any serious non-trivial project. Therefore implement them once and then use everywhere. Ultimately task scheduler and software timers changes software architecture and your way of thinking forever and enables you to write actually useful systems, not only Arduino style "Hello world!"-s.
2020-01-20 04:03 AM
Check your clock configuration, because APB1 timer clock is at most 90 MHz.
2020-01-20 07:09 AM
If APB divider is not 1, TIM is usually not clocked at APB clock but at twice that. Read the RCC chapter.
JW