Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Main code of firmware
- */
- #include "stm32f10x.h"
- #include "core_cm3.h"
- #include "main.h"
- /* user status flag */
- volatile unsigned char status_flag;
- void main();
- /* Main function */
- void main(void) {
- //status_flag = 0;
- /* setup i/o port c */
- RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
- LED_PORT->CRH |= GPIO_CRH_MODE8_0 | GPIO_CRH_MODE9_0;
- LED_PORT->CRH &= ~(GPIO_CRH_CNF8 | GPIO_CRH_CNF9);
- /* setup i/o port a */
- RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_AFIOEN;
- /* setup AFIO andEXTI */
- AFIO->EXTICR[0] |= AFIO_EXTICR1_EXTI0_PA;
- EXTI->IMR |= (1 << 0);
- EXTI->FTSR |= (1 << 0);
- /* setup TIM6 */
- RCC->APB1ENR |= RCC_APB1ENR_TIM6EN;
- TIM6->PSC = 8000 - 1;
- TIM6->ARR = 1000;
- TIM6->DIER |= TIM_DIER_UIE;
- /* enable TIM6 */
- TIM6->CR1 |= TIM_CR1_CEN;
- /* enable TIM6_DAC interrupt */
- NVIC_EnableIRQ(TIM6_DAC_IRQn);
- /* enable EXTI0 interrupt */
- NVIC_EnableIRQ(EXTI0_IRQn);
- /* enable leds */
- LED_PORT->ODR = LED_BLUE | LED_GREEN;
- /* infinity loop */
- while (1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement