2023-05-10 03:57 AM
I am using STM32F030C8T6TR.
I have a process that needs to be counted precisely, so I'm connecting a timer oven oscillator with an extenal clock mod 2. How many MHz can I use( for maximum)? I'm using an internal clock for processor, it works at maximum 48 mhz.
TIM1->CR1 &= (uint16_t)(~(TIM_CR1_DIR | TIM_CR1_CMS | TIM_CR1_CKD));
TIM1->ARR = 40500 - 1 ;
TIM1->PSC = 0x0000;
TIM1->CCMR1 &= (uint16_t)~TIM_CCMR1_IC1F; // input filter
TIM1->CCER = TIM_CCER_CC1P; // positive edge
TIM1->SMCR &= (uint16_t)~(TIM_SMCR_SMS | TIM_SMCR_TS | TIM_SMCR_ECE);
TIM1->SMCR |= (uint16_t)(TIM_TS_TI1FP1 | TIM_SMCR_SMS); // external mode 1
The second thing I want to ask is what kind of process is it running in the background while the timer counter setting zero (TIM1->CNT = 0). To try this, I did a led turn-off operation. When I reset the timer, the time elapsed takes about 1 microsecond more than the time I did not reset it. But I need to reset it for the operation. I hope I was able to explain :))
Thanks for now
2023-05-10 05:24 AM - edited 2023-11-20 05:51 AM
> with an extenal clock mod 2.
> TIM1->SMCR |= (uint16_t)(TIM_TS_TI1FP1 | TIM_SMCR_SMS); // external mode 1
So, mode 1 or mode 2?
Although in both cases, the maximum input clock frequency is internal timer clock frequency / 2:
> I hope I was able to explain
No.
> To try this, I did a led turn-off operation.
What is that?
2023-05-10 05:36 AM
Why wouldn't you use the OCXO clock to run the MCU / PLL ? Should have fHSEext of 48 MHz
A slow MCU with 16-bit TIM, probably a poor choice for precision timing.
There should be an ETR connection allowing the TIM to reset against a 1PPS edge (or whatever), in HW with no SW or interrupt latency.
2023-05-10 05:48 AM
The schematic pcb is not mine and the external oscillator is not connected to the processor.