2020-01-22 11:12 PM
What i am currently using to achieve my goal.
Few Details :
1: STM32F103C8 Blue Pill
2: CMISS core Library
3:Datasheet, Reference Manual and Programming Manual
I have attached two files. Which give you some idea that how I want to make These 3 functions. I want to understand at Register level.
I want to configure Registers by myself.
Thanks & Regards
@Vivek yadav
2020-01-22 11:34 PM
Well just stop timer change value of arr, start timer? Or use 3 timers for this? Bluepill have 4 timers.
2020-01-23 12:19 AM
I would suggest to use symbolic names (preprocessor constants) instead of "magic" numbers.
Hardly anyone want's to browse forth and back through the the reference manual while reading your code. This will include you in a few weeks ...
The stm32f1xx.h header file provided by ST would do no harm.
A nanoseconds delay would work down to the granularity of the counter used (clock, prescaler).
However, indeterminisms like interrupts or DMA transfers will introduce jitter significant in relation to the desired delay.
For milliseconds delays, you could use the SysTick timer as well.
2020-01-23 12:29 AM
@oeliks
Q.1 : How can we set our Controller to its Maximum Speed(max. 72Mhz)?
What value I have to change in my RCC Registers. I have a doubt because we have only 8 Mhz External oscillator.
Q.2: As I can See in datasheet that Timer1 has 16 bit Register Which means it can have maximum 65536[0 to 65535] and if we
calculate we get that This Register( TIMx_CNT ) will over Flow 122 times.
it means in 1 sec it is counting 122 times.
Am i right ????
2020-01-23 12:40 AM
@Ozone Thanks
I definitely use stm32f1xx.h header file.
2020-01-23 01:08 AM
SysTick is a 24-bit timer in the core space (present in all Cortex M devices), with it's own fixed interrupt hander.
The CMSIS libs use to contain easy-to-use setup function.
BTW, the F10x MCUs had been covered by the now obsolete Standard Peripheral Library, which is still available for download.
Much simpler and straightforward then Cube/HAL, I would recommend to download and use the examples as template for your applications.
And even if it's only the sequence of peripheral initialization operations.
2020-01-23 08:25 PM
If You cant calculate values of Your PLL manually try to use cubemx clock tool, it will do it for You. Its possible to set pll to 72mhz with just 8mhz hse in this device.
Almost all tutorials with stm show how to set clocks.
72mhz=1.3838E-8 [s]
1.39E-8 * (122 * 65535) = time [s]
=)
2020-01-25 01:18 AM
timer is works three main fundamentals , timer clock ,prescaler and period , once you understand this it is easy for you
2020-01-25 01:19 AM
refrence manual
2020-01-25 01:33 AM
@dbgarasiya
can You Check This ?
/*
* @Beirf : This is my attempt to make my own delay funcation.
* with my limited knowledge of ARM Cortex M3 Registers.
* Delay Should be in milli Seconds
* I am using PLL clock as System Clock at 72 Mhz.
*
*
*/
void my_msDelay(uint32_t Delay)
{
// Enable PLL Clock. and check Ready flag
RCC->CR |= 1<<24;
while(RCC->CR != (1<<25))
{
/* Wait */
}
//Select PLL as SYSTEM clock
RCC->CFGR |= 0x10 << 0;
// Run at it maximal Value. which is 72 Mhz for STM32f103c8(Blue Pill)
RCC->CFGR |= 0x0111 << 18;
// Enable Timer 1
RCC->APB2ENR |= 1<<11;
// Enable Timer CEN bit
TIM1->CR1 |= 1<<0;
// Load Value in Prescaler
TIM1->PSC = 1;
//Now how would i calculate 1 sec time delay
}