Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- JoergSturm
- Date:
- 2020-03-01
- Revision:
- 0:45170c77adc7
- Child:
- 1:17722afc5909
File content as of revision 0:45170c77adc7:
#include "mbed.h"
//#include "cmsis_nvic.h"
DigitalOut myled(PC_0);
static void TIM6_Init(void);
static void NVIC_Init(void);
void TIM6_IRQHandler(void);
TIM_HandleTypeDef htim6;
void TIM6_IRQHandler(void)
{
myled=!myled;
TIM6->SR=0;
HAL_NVIC_ClearPendingIRQ(TIM6_IRQn);
}
static void NVIC_Init(void)
{
/* TIM6_IRQn interrupt configuration */
HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0);
NVIC_SetVector(TIM6_IRQn, (uint32_t)&TIM6_IRQHandler);
HAL_NVIC_EnableIRQ(TIM6_IRQn);
}
/* TIM6 init function */
static void TIM6_Init(void)
{
/*
__TIM6_CLK_ENABLE();
htim6.Instance = TIM6;
htim6.Init.Prescaler = 3200;
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
htim6.Init.Period = 5000;
if (HAL_TIM_Base_Init(&htim6) != HAL_OK) {
while(1) {
}
}
HAL_TIM_Base_Start_IT(&htim6);
*/
RCC->APB1ENR|=0b10000; //Clock Enable
TIM6->PSC=3200; //Prescaler 100µs
TIM6->ARR=5000; //Autoreload 5000*100µs = 0,5s
TIM6->DIER=1; //UIE = 1 (Update Interrupt Enable)
TIM6->SR=0; //UIF =0 (Update Interrupt Flag)
TIM6->CR1=1; //CEN=1 (Counter Enable)
}
int main()
{
TIM6_Init();
NVIC_Init();
while(1) {
/*
if (TIM6->SR==1)
{
TIM6->SR=0;
myled=!myled;
}
*/
}
}