2019-05-22 03:05 AM
#include "stm32f10x.h"
void init();
void Timer_delay();
void main()
{
init();
Timer_delay();
while(1)
{
while(TIM3->SR & 0x0001)/*Check the TIM3 update interrupt occurs or not*/
TIM3->SR = 0x0000;/*Remove TIMx update interrupt flag */
GPIOA->BSRR^=0X00000002;
}
}
void init()
{
RCC->APB2ENR=0x00000004;
GPIOA->CRL = 0x00000010;
}
void Timer_delay()
{
//Timer Configuration..//
RCC->APB1ENR = 0X00000002; //Timer3 clock enable..//
TIM3->ARR = 500; //Auto Reload value..//
TIM3->PSC = 64000; //Prescaler value.//
TIM3->CR1= 0X0000; //Clock division & Upcounter mode
//Interrupt Config..//
TIM3->DIER = 0X0001; //Update interrupt Enabled..//
TIM3->CR1= 0X0001; //Counter Enabled..//
}
2019-05-22 07:32 AM
> GPIOA->BSRR^=0X00000002;
As BSRR is a write-only register and reads always as 0, this is effectively the same as
GPIOA->BSRR=0X00000002;
which always only sets PA1.
JW
2019-05-22 08:16 AM
Try GPIOA->ODR ^=0x0002; // Toggle PA1
2019-05-23 12:06 AM
yes! i got no errors,but unfortunately i'm unable to get an output in proteus simulation.
2019-05-23 10:25 PM
as far now im not getting any errors or warning in my program,but while simulating in proteus im not getting the output as per the program.Below is my proteus connection.Kindly help me to overcome from this.
2019-05-24 01:12 AM
Would this be a real-world circuit, the LED would blow as soon as you switch PA1 high. The resistor should be in series with the LED.
JW
2019-05-24 09:50 PM
Hi,
im not getting anything from this,kindly someone please send me a code structure or step by step coding instructions for creating delay using timer with stm32f103r8.
it will be helpful.
2019-05-25 04:38 AM
Well, there are STM32 Cube library with many folders for existing boards. Hunt for a Nucleo using your STM32 family and look at sub folder TIMER examples.
Applications goal is to demonstrate the peripheral functionality, then you'll have to build the application delay desired functionality on top of it.
Otherwise, HAL_Delay() in msec unit.