티스토리 뷰










#include "stm32f10x.h"


void TIM2_IRQHandler();         //함수 선언


unsigned int count=0;


int main(void)
{
 RCC->APB2ENR|=0x8;   //GPIOB 활성화
 RCC->APB1ENR|=0x1;    //TIM2 활성화
 NVIC->ISER[0]|=(0x1<<28);  //타이머 enable
 
 TIM2->CR1 =  0x5; //355p
 TIM2->ARR = 7199; // period
 TIM2->PSC = 99;  // prescaler

 NVIC->IP[28]=0x01;  //인터럽트 우선순위를 설정하는 레지스터입니다(지금은 사용하지 않습니다)
 TIM2->DIER=0x1;  //360p  1: Update interrupt enabled.
 TIM2->EGR=0x1;  //363p
 
 GPIOB->CRL=(0x3<<20);
 
 while(1)
 {
  
 }
 return 0;
}

void TIM2_IRQHandler()
{
 count ++;
 if(count==100)
 {
  GPIOB->BSRR=(0x1<<5);
 }
 if(count==200)
 {
  count=0;
  GPIOB->BRR=(0x1<<5);
 }
 TIM2->SR &=~(0x1<<0);


}





























댓글
공지사항
최근에 달린 댓글
Total
Today
Yesterday
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31