Using Timer
main.c
#include "stm32f1xx.h"
#include "LCDFunctions.h"
int main(void)
{
InitializePortsForLCD();
LCDDisplaySetup();
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // Supply clock to TIM1
TIM1->CR1 |= TIM_CR1_CEN; //Enable Timer
TIM1->PSC |= 655; //Prescalar value
LCDSendStringsIn2Lines("Counter: ", "Prescalar:");
LCDsendAnInteger(TIM1->PSC, 5);
while(1)
{
LCDSetCursorPosition(9,0);
LCDsendAnInteger(TIM1->CNT,6); //Timer Count
}
}
#include "stm32f1xx.h"
#include "LCDFunctions.h"
int main(void)
{
InitializePortsForLCD();
LCDDisplaySetup();
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // Supply clock to TIM1
TIM1->CR1 |= TIM_CR1_CEN; //Enable Timer
TIM1->PSC |= 655; //Prescalar value
LCDSendStringsIn2Lines("Counter: ", "Prescalar:");
LCDsendAnInteger(TIM1->PSC, 5);
while(1)
{
LCDSetCursorPosition(9,0);
LCDsendAnInteger(TIM1->CNT,6); //Timer Count
}
}
Comments
Post a Comment