본문 바로가기
프로그래밍

ARM실습_SPL를 이용하여 GPIO를 해보자

by BlueOcean&Shark 2016. 12. 14.

#include "stm32f10x.h"

void main(void)
{
   // GPIO구조체 선언
   GPIO_InitTypeDef GPIO_InitStructure;
   
   // APB2_GPIOF를 ENABLE
   참고  http://munshark.tistory.com/100

   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF, ENABLE);
  
   /* GPIOF포트의 6번핀과 7번핀을 
      50MHz의 속도와 push-pull로 설정 후 초기화 */

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
   GPIO_Init(GPIOF, &GPIO_InitStructure);
 
   while(1)
   {
     // GPIOF포트의 6번핀과 7번핀을 셋
     GPIO_WriteBit(GPIOF, GPIO_Pin_6 | GPIO_Pin_7 , Bit_SET);
     for(uint32_t  i = 0 ; i < 72000000/16 ; i++)
     {
        __NOP();
     }
     // GPIOF포트의 6번핀과 7번핀을 리셋
     GPIO_WriteBit(GPIOF, GPIO_Pin_6 | GPIO_Pin_7, Bit_RESET);
     for(uint32_t i = 0 ; i < 72000000/16 ; i++)
     {
        __NOP();
     }
   }
}

댓글