![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Testprogramm für Hardwaretimer TIM2 und TIM3 mit Nucleo-F401RE
Diff: main.cpp
- Revision:
- 1:17722afc5909
- Parent:
- 0:45170c77adc7
- Child:
- 2:a5ee88ab46b2
--- a/main.cpp Sun Mar 01 10:08:57 2020 +0000 +++ b/main.cpp Fri Apr 24 14:13:21 2020 +0000 @@ -1,13 +1,18 @@ #include "mbed.h" -//#include "cmsis_nvic.h" + DigitalOut myled(PC_0); -static void TIM6_Init(void); -static void NVIC_Init(void); +DigitalOut PC1(PC_1); -void TIM6_IRQHandler(void); +void EX1IRQhandler(void) +{ + //PC1=!PC1; + GPIOC->ODR=~GPIOC->ODR; + EXTI->PR=0b10; + HAL_NVIC_ClearPendingIRQ(EXTI1_IRQn); +} -TIM_HandleTypeDef htim6; +//TIM_HandleTypeDef htim6; void TIM6_IRQHandler(void) { myled=!myled; @@ -15,12 +20,22 @@ HAL_NVIC_ClearPendingIRQ(TIM6_IRQn); } +void EX1init(void) +{ +RCC->AHBENR|=0b111; +GPIOA->PUPDR|=0b1000; +EXTI->IMR|=0b10; +EXTI->RTSR|=0b10; +} + static void NVIC_Init(void) { /* TIM6_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0); + //HAL_NVIC_SetPriority(TIM6_IRQn, 0, 0); NVIC_SetVector(TIM6_IRQn, (uint32_t)&TIM6_IRQHandler); HAL_NVIC_EnableIRQ(TIM6_IRQn); + NVIC_SetVector(EXTI1_IRQn, (uint32_t)&EX1IRQhandler); + HAL_NVIC_EnableIRQ(EXTI1_IRQn); } /* TIM6 init function */ @@ -50,6 +65,7 @@ int main() { TIM6_Init(); + EX1init(); NVIC_Init(); while(1) { /*