'중도연재종료'에 해당되는 글 37건

  1. 2013.09.02 엔코더값 읽기.
  2. 2013.09.02 Cortex M3 블루투스 설정
  3. 2013.09.02 Bluetooth 사용기(팁 포함)
  4. 2013.09.02 스텝모터 돌리기
  5. 2013.06.23 진행방식을 바꾼다...
  6. 2013.06.23 함수표 참조 설명
  7. 2013.06.23 함수표
  8. 2013.06.23 정확한 1초 Delay 구현
  9. 2013.06.23 RCC_GetClockFreq
  10. 2013.06.23 Clock Control

한시간이면 될것을 몇일 걸린 이유...


1. 선이 끊어져 있는데 이걸 발견하지 못했다..    :단선 확인은 필수다

2. GND끼리 연결하지 않았다.

MCU랑 연계해서 값을 읽는다고 한다면 하나의 회로를 이루어야 한다. 전원은 따로더라도 엔코더쪽 GND따로 MCU쪽 GND따로가 아니라는 말씀. 두 GND를 연결해주자. 그러지 않으면 값이 불규칙적이다.


엔코더가 제대로 돌아가는지 확인하는법.

엔코더에 전원을 연결해 주고, 엔코더의 A B상 출력과 GND사이에 각각 LED를 연결해준다.

엔코더를 돌릴때 두 LED가 깜빡여야 한다. 계속 켜져있거나 계속 꺼져있으면 불량이다.


//******************************************************************

헤더


#include <stm32f10x_it.h>


void Encoder_RCC(void);

void Encoder_GPIO(void);

void Encoder_TIM(void);

void Encoder_Setting(void);

void Encoder_NVIC(void);


void Encoder_Disable(void);


저번과 같은 맥락의 함수들이다

//*********************************************************************

본문


1. TIM3 사용, PortC로 Remapping할것임. 본래 타이머 외의 용도를 사용하기 위해서 AFIO를 Enable

void Encoder_RCC(void){

  //PortC TIM3

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO,ENABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);

}


2. TIM3를 Full-Remap하여 PortC의 핀6~9를 TIM3로 사용

void Encoder_GPIO(void){

  GPIO_InitTypeDef GPIO_InitStructure;


  GPIO_PinRemapConfig ( GPIO_FullRemap_TIM3, ENABLE );

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;//GPIO_Mode_IN_FLOATING;//

  GPIO_Init(GPIOC,&GPIO_InitStructure); 

}


3.

TIM_EncoderInterfaceConfig : 엔코더 설정 함수. 타이머, 엔코더 모드, A B 상의 펄스읽는 방식 설정

TIM_ARRPreloadConfig : Enables or disables the TIM peripheral Preload register on ARR.

//타이머카운터의 기본기능이 아닌 다른 기능을 사용하기 위한 함수라는데 모르겠다.

TIM_ClockDivision : 분주비. 본인은 4분주 사용

TIM_ITConfig : 타이머 인터럽트 활성화


void Encoder_TIM(void){

  TIM_EncoderInterfaceConfig(TIM3, TIM_EncoderMode_TI12, TIM_ICPolarity_Rising, TIM_ICPolarity_Rising);

  TIM_ARRPreloadConfig(TIM3, ENABLE);

  TIM_Cmd(TIM3, ENABLE);

  //***************************************************************

  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;


  TIM_TimeBaseStructure.TIM_Period = 500;//260;//624;

  TIM_TimeBaseStructure.TIM_Prescaler = 1;//576;

  //

  

  TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV4;//TIM_CKD_DIV1;//TIM_CKD_DIV4;//

  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //upcounting mode

  //TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; 


  TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

  TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE); 

}


void Encoder_NVIC(void){

  NVIC_InitTypeDef NVIC_InitStructure;

  

    NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;            


    //NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 6;


    //NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;


    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;


    NVIC_Init(&NVIC_InitStructure);

}


void Encoder_Setting(void){

  Encoder_RCC();

  Encoder_GPIO();

  //Encoder_NVIC(); //인터럽트 없었음.. 그 자체로 모터의 펄스값을 읽어들였음. 전에 시험테스트 해볼때도

  Encoder_TIM();

}


void Encoder_Disable(void){

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO,DISABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,DISABLE);

  

  TIM_ARRPreloadConfig(TIM3, DISABLE);

  TIM_Cmd(TIM3, DISABLE);

  TIM_ITConfig(TIM3, TIM_IT_Update, DISABLE); 

}



'중도연재종료 > CORTEX M3' 카테고리의 다른 글

Cortex M3 블루투스 설정  (0) 2013.09.02
Bluetooth 사용기(팁 포함)  (0) 2013.09.02
스텝모터 돌리기  (0) 2013.09.02
진행방식을 바꾼다...  (0) 2013.06.23
함수표 참조 설명  (0) 2013.06.23
Posted by 십자성군

지금 하고있는 졸작 프로젝트에 맞춘것임. 용도불명인 내용이 많을 수 있음.

Bluetooth.zip


헤더부터 살펴보면

1.

#define GPIO_Bluetooth  GPIOA

#define GPIO_Bluetooth_Rx_Pin GPIO_Pin_3

#define GPIO_Bluetooth_Tx_Pin GPIO_Pin_2


PortA의 2번과 3번핀을 사용하였다. Cortex회로도를 보면 알겠지만 각각 USART2의 TX와 RX이다.


//-----------------Buffer Size-------------------------

#define U2_BUFFER_SIZE 100

//----------------------------------------------------

void Blutooth_RCC_Configuration(void);

void Blutooth_NVIC_Configuration(void);

void Blutooth_GPIO_Configuration(void);

void Blutooth_UART2_Configuration(void);

void Blutooth_Setting(void);    //위의 RCC~UART2까지를 함수하나로 부르려고 한것이다.


//void USART2_IRQHandler(void);

void PutChar_blue(uint8_t c);        //블루투스에 한문자를 전송

void PutString_blue(uint8_t *s);    //문자단위로 문자열을 전송

void Send_Command_test(uint16_t Command);    //전송테스트용. 패킷을 위루어 전송

void Transmit_data(uint8_t *s);    //실질적으로 문자단위로 전송하는 부분

//********************Status Test**************************

bool input_check(void);

bool Connection_Check(void);

//********************Send Speed***************************

void Send_EncoderState(uint16_t Speed);



그냥보면은 용도를 알 수 없는 함수가 꽤 있다. 실제 내가 복습하려고 만들어 놓은 내용이니..

몇곳만 짚어 적어둔다.


1.NVIC : 실제로는 부르지 않게 해놓았다. 이걸 부르면 어쩐지 시리얼 통신부분에서 진행하질 못한다. 딱히 할 필요성은 못느낌

2.USART_ITConfig     수신에 대한 인터럽트를 가능하게 해준단다.

3.USART_SendData(USART2,c);    데이터 보낼 때

4.

intData=0;

  Command_Data[4]=(0x00ff)&intData;

  Command_Data[3]=((0xff00)&intData)>>8;


intData에 저장한 값을 PC가 받게 하려고 할 때, 다음과 같이 넣어서 보내면 의도한 값을 컴퓨터에서 받을 수 있다.

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

엔코더값 읽기.  (0) 2013.09.02
Bluetooth 사용기(팁 포함)  (0) 2013.09.02
스텝모터 돌리기  (0) 2013.09.02
진행방식을 바꾼다...  (0) 2013.06.23
함수표 참조 설명  (0) 2013.06.23
Posted by 십자성군

나같이 아무것도 모르는 채로 맨땅에 헤딩하는 사람들을 위한 블루투스 사용기...

대상은 펌테크의 FB155BC_SMD



메뉴얼을 보면 어떠한 명령이 있다던가 다 나와있지만, '정말 아무것도 모르는 사람'들을 위한 개략적인 설명.


인터페이스 보드가 없다. 하지만 설정은 하고싶다. 이때 AT명령어를 이용한 설정을 하면 된다고 한다.

AT명령어 관련은 관련 메뉴얼을 보면 되지만 'AT명령어를 어떻게 사용하지?'라는 것에 대한 언급은 없다...


디바이스마트에서 판매하는 단가 6000원? 정도의 RS232 통신모듈을 사용하면 된다. 또는 소자 몇개 가지고 스스로 만들면 된다.(본인의 경우 원치않게 만들어 사용했음) 모듈의 TX, RX를 블루투스의 RX, TX에 각각 연결해준다. 물론 블루투스와 RS232모듈 둘다 전원이 들어가 있어야 겠지... 테라텀으로는 자신이 전송하는 내용을 보는 방법을 모르겠으니,  ComportMaster 또는 하이퍼터미널로 신호를 보낸다. 하이퍼 터미널에서 자신이 보내는 내용을 보는 방법은 네이버에서 쉽게 찾을 수 있다(Property로 들어가면 된다) ComportMaster사용을 추천.

나머지는 메뉴얼대로 신호를 주고 받으면 된다.


팁1.

후배에게서 받은 팁.

공장에서 막 생산된 상태의 공장초기화를 하려면?

3번 Status에서 핀을 뽑아서, GND에 잠시 연결한 후 뗀다. 그러면 모든 설정이 초기화 된다.


팁2.

이 역시 후배에게서 받은 팁.

인터페이스 보드에서 나오는 메뉴를 사용하는 설정을 하고 싶은 경우.

3번 Status와 GND를 잠시 연결한 후 뗀다.


위에꺼랑 뭐가 다르냐면...

팁1도 팁2도 물론 전원이 들어간 상태에서 하는건데. 팁2의경우, Serial통신 창을 열어놓은 상태라면 알겠지만 GND에 데었다 떼면 인터페이스보드를 사용할때와 같은 메뉴가 나온다(이미 공장초기화 된 상태). 그상태에서 전원의 재인가 없이 설정을 진행한 후 종료했다 켜면 설정이 적용된 상태로 사용 가능한것. 팁1의 경우 전원을 재인가 해서 설정없이 말그대로 공장초기화 된것

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

엔코더값 읽기.  (0) 2013.09.02
Cortex M3 블루투스 설정  (0) 2013.09.02
스텝모터 돌리기  (0) 2013.09.02
진행방식을 바꾼다...  (0) 2013.06.23
함수표 참조 설명  (0) 2013.06.23
Posted by 십자성군

스텝모터 돌리기 전에... 회로에 대한 기초 이론이 부족했기에.. 조금 조사해둔 내용


2상 여자라던가 이런부분은 알고있으니, 다른 내용 정리


D-CUT SHAFT : 모터 단독 제품. 그렇지 않을 경우 감속기 부착용


모터드라이버를 이용하여 모터에 전압과 전류를 공급한다.


그런데 공급하는 전압과 전류가 규정치를 넘어서 걱정이 된다. 이에 대한 내용


모터 스펙에 나와있는 전압은 정격전류를 흘리기 위한 최소전압이라 한다.

보통 표시된 전압의 4배정도의 전압을 공급한다.

표시된 전압만큼만 공급해도 규정 토크는 나오지만 최고 회전속도를 약간 더 올려주기 위해서,

그리고 높은 회전속도에서 토크저하를 줄이기 위해서 표시된 전압보다 4~8배 정도 높은 전압을 주는것이 유리하다.


모터드라이버 회로에서 모터의 규정전압을 넘는 전압을 인가하여도 토크는 동일하다.

예를들어 2V 1A모터에 16V를 인가한다 하더라도 전류가 1A를 넘는 순간 전압을 끊고, 조금 기다렸다가 다시 전원을 인가하는 동작(Chopping에 의한 전류제한)을 하기 때문에 항상 모터에는 1A의 평균/실효 전류가 흐른다.

모터의 자속은 전류X권선 회수에 직접 비례한다. 전압의 요소가 없다는 점을 상기하자

다만 고전압을 인가햇을 때 1A까지 전류가 상승하는 시간이 저전압보다 짧기 때문에 상대적으로 약간 더 토크가 크게 느껴지고 고속 회전에 유리해진다.


스텝모터는 정전류 구동형이다. 코일전압은 큰 의미가 없다.

전압이 높으면 홀딩토크는 커질것이나 일반적으로 크기 필요하지는 않다.

전압이 낮은쪽이 역기전력이 작다. 따라서 낮은 전압의 고 전류급 모터를 추천한다고 한다.(3V이상 되지 않도록)


파워서플라이 등으로 스텝모터를 구동할때.. 이런 질문이 있었다고 한다.

5V 20A를 회로에 공급하면 과전류로 인해서 회로에 열이 과다하게 발생하거나 혹은 손상이 가지 않는지요?

그리고 스텝모터 구동드라이버에도 12V, 17A면 전류 과다로 모터나 회로에 이상이 발생하지 않는가요?

모터 구동하는데 전류가 중요한데 보통 3A면 되는데 17A까지 공급되어도 되나요?


:전류는 필요한 만큼만 사용됩니다. 공급하는 측에서 남아돈다고 해서 무조건 다 흘러 들어가는 것이 아닙니다.

전류가 모자라면 문제가 됩니다만 남는 것은 사용되지 않습니다.

----------------------

스테핑 모터 스펙이 5V라도 정격으로 주어지는 전압을 사용하는게 좋다. 모터 컨트롤러의 정격을 알아보고 거기에 맞는 전압을 넣어주자.  적거나 무부하시 10 또는 12V라도 잘 돌아가는 이유는 스텝모터 구동부 내부에서 24V를 생성해 주기 때문이지만, 이런 전압변환에서는 전압이 낮아지는 대신 내부에 흐르는 전류가 높아지기 때문에 과열이 날 수 있다. 따라서 24V를 공급하는 것이 좋다. W=IV인데 I를 맞추고 V가 낮으면 돌아갈수는 있어도 내부전류가 높아져서 과열발생, 전류가 충분히 공급되지 않으면 전압이 불안정해지면서 구동부에 열 발생. 방열판 추가 장착이 필요할 수 있음.

모터 구동부로 가는 선이 너무 얇으면 충분한 전류가 전달될 수 없어서 모터 구동부에서 열이 발생


결론:

주어진 전류값은 지켜준다.

전압값은 4~8배가 될 수 있도록.

정격전압 24V정도로 맞춰주자.

모터 구동부로 가기 위한 선은 굵게 해주자


'중도연재종료 > CORTEX M3' 카테고리의 다른 글

Cortex M3 블루투스 설정  (0) 2013.09.02
Bluetooth 사용기(팁 포함)  (0) 2013.09.02
진행방식을 바꾼다...  (0) 2013.06.23
함수표 참조 설명  (0) 2013.06.23
함수표  (0) 2013.06.23
Posted by 십자성군

당연히 모듈의 사용방법은 알아야 하지만, 이게 내부가 어떻게 되어있는지까지 빠삭하게 알 필요는 없지...

중요한건 어떻게 사용할지 이니까. 공부해야 할건 다른데도 얼마나 많은데 이걸 다 뒤져보고 있대...

마침, Zigbee 및 RTOS 건너뛰고 다음권 부터는 사용방법, 함수 위주 및 실습 위주로 해야겠다.

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

Bluetooth 사용기(팁 포함)  (0) 2013.09.02
스텝모터 돌리기  (0) 2013.09.02
함수표 참조 설명  (0) 2013.06.23
함수표  (0) 2013.06.23
정확한 1초 Delay 구현  (0) 2013.06.23
Posted by 십자성군

1 Document and library rules         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

2 Firmware library     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

3 Peripheral firmware overview         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

4 Analog/digital converter (ADC)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

5 Backup registers (BKP)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

6 Controller area network (CAN)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

7 DMA controller (DMA)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

8 External interrupt/event controller (EXTI)             . . . . . . . . . . . . . . . . . . . . . . 136

9 Flash memory (FLASH)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

10 General purpose I/O (GPIO)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

11 Inter-integrated circuit (I2C)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

12 Independent watchdog (IWDG)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

13 Nested vectored interrupt controller (NVIC)             . . . . . . . . . . . . . . . . . . . . 220

14 Power control (PWR)     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

15 Reset and clock control (RCC)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

16 Real-time clock (RTC)     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

17 Serial peripheral interface (SPI)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

18 Cortex system timer (SysTick)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

19 Advanced-control timer, general-purpose timer and

20 Universal synchronous asynchronous receiver

21 Window watchdog (WWDG)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

22 Digital/analog converter (DAC)         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

23 Flexible static memory controller (FSMC)             . . . . . . . . . . . . . . . . . . . . . 457

24 SDIO interface (SDIO)     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

25 Debug MCU     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515

26 CRC calculation unit     . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519





'중도연재종료 > CORTEX M3' 카테고리의 다른 글

스텝모터 돌리기  (0) 2013.09.02
진행방식을 바꾼다...  (0) 2013.06.23
함수표  (0) 2013.06.23
정확한 1초 Delay 구현  (0) 2013.06.23
RCC_GetClockFreq  (0) 2013.06.23
Posted by 십자성군

최초에 첨부한 파일중 함수 메뉴얼의 함수목록


1 Document and library rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

1.1 Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

1.2 Naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

1.3 Coding rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

1.3.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

1.3.2 Boolean type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

1.3.3 FlagStatus type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

1.3.4 FunctionalState type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

1.3.5 ErrorStatus type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

1.3.6 Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39


2 Firmware library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

2.1 Package description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

2.1.1 Examples folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

2.1.2 Library folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

2.1.3 Project folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

2.2 Description of firmware library files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

2.3 Peripheral initialization and configuration . . . . . . . . . . . . . . . . . . . . . . . . . 46

2.4 Bit-Banding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

2.4.1 Mapping formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

2.4.2 Example of implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

2.5 Run-time checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48


3 Peripheral firmware overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51


4 Analog/digital converter (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

4.1 ADC register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

4.2 ADC library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

4.2.1 ADC_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

4.2.2 ADC_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

ADC_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

4.2.3 ADC_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

4.2.4 ADC_Cmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

4.2.5 ADC_DMACmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

4.2.6 ADC_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

4.2.7 ADC_ResetCalibration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

4.2.8 ADC_GetResetCalibrationStatus function . . . . . . . . . . . . . . . . . . . . . . . 63

4.2.9 ADC_StartCalibration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

4.2.10 ADC_GetCalibrationStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

4.2.11 ADC_SoftwareStartConvCmd function . . . . . . . . . . . . . . . . . . . . . . . . . 65

4.2.12 ADC_GetSoftwareStartConvStatus function . . . . . . . . . . . . . . . . . . . . . 65

4.2.13 ADC_DiscModeChannelCountConfig function . . . . . . . . . . . . . . . . . . . 66

4.2.14 ADC_DiscModeCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

4.2.15 ADC_RegularChannelConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . 67

4.2.16 ADC_ExternalTrigConvCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

4.2.17 ADC_GetConversionValue function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

4.2.18 ADC_GetDualModeConversionValue function . . . . . . . . . . . . . . . . . . . 70

4.2.19 ADC_AutoInjectedConvCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . 70

4.2.20 ADC_InjectedDiscModeCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . 71

4.2.21 ADC_ExternalTrigInjectedConvConfig function . . . . . . . . . . . . . . . . . . . 71

4.2.22 ADC_ExternalTrigInjectedConvCmd function . . . . . . . . . . . . . . . . . . . . 73

4.2.23 ADC_SoftwareStartInjectedConvCmd function . . . . . . . . . . . . . . . . . . . 73

4.2.24 ADC_GetSoftwareStartInjectedConvStatus function . . . . . . . . . . . . . . . 74

4.2.25 ADC_InjectedChannelConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . 75

4.2.26 ADC_InjectedSequencerLengthConfig function . . . . . . . . . . . . . . . . . . 76

4.2.27 ADC_SetInjectedOffset function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

4.2.28 ADC_GetInjectedConversionValue function . . . . . . . . . . . . . . . . . . . . . 77

4.2.29 ADC_AnalogWatchdogCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

4.2.30 ADC_AnalogWatchdogThresholdsConfig function . . . . . . . . . . . . . . . . 79

4.2.31 ADC_AnalogWatchdogSingleChannelConfig function . . . . . . . . . . . . . . 79

4.2.32 ADC_TempSensorVrefintCmd function . . . . . . . . . . . . . . . . . . . . . . . . . 80

4.2.33 ADC_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

4.2.34 ADC_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

4.2.35 ADC_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

4.2.36 ADC_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82


5 Backup registers (BKP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.1 BKP register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

5.2.1 BKP_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

5.2.2 BKP_TamperPinLevelConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . 87

5.2.3 BKP_TamperPinCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

5.2.4 BKP_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

5.2.5 BKP_RTCOutputConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

5.2.6 BKP_SetRTCCalibrationValue function . . . . . . . . . . . . . . . . . . . . . . . . . 89

5.2.7 BKP_WriteBackupRegister function . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

5.2.8 BKP_ReadBackupRegister function . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

5.2.9 BKP_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

5.2.10 BKP_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

5.2.11 BKP_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

5.2.12 BKP_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93


6 Controller area network (CAN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

6.1 CAN register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

6.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

6.2.1 CAN_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

6.2.2 CAN_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

CAN_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

6.2.3 CAN_FilterInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

CAN_FilterInitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

6.2.4 CAN_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

6.2.5 CAN_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

6.2.6 CAN_Transmit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

CanTxMsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

6.2.7 CAN_TransmitStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

6.2.8 CAN_CancelTransmit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

6.2.9 CAN_FIFORelease function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

6.2.10 CAN_MessagePending function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

6.2.11 CAN_Receive function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

CanRxMsg structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

6.2.12 CAN_Sleep function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

6.2.13 CAN_WakeUp function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

6.2.14 CAN_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

6.2.15 CAN_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

6.2.16 CAN_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

6.2.17 CAN_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116


7 DMA controller (DMA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

7.1 DMA register structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

7.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

7.2.1 DMA_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

7.2.2 DMA_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

DMA_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

7.2.3 DMA_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

7.2.4 DMA_Cmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

7.2.5 DMA_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

7.2.6 DMA_GetCurrDataCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . 129

7.2.7 DMA_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130

7.2.8 DMA_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

7.2.9 DMA_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

7.2.10 DMA_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135


8 External interrupt/event controller (EXTI) . . . . . . . . . . . . . . . . . . . . . . 136

8.1 EXTI register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

8.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

8.2.1 EXTI_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

8.2.2 EXTI_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138

EXTI_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

8.2.3 EXTI_Struct function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

8.2.4 EXTI_GenerateSWInterrupt function . . . . . . . . . . . . . . . . . . . . . . . . . . 142

8.2.5 EXTI_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

8.2.6 EXTI_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

8.2.7 EXTI_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143

8.2.8 EXTI_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144


9 Flash memory (FLASH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

9.1 FLASH register structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

9.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

9.2.1 FLASH_SetLatency function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

9.2.2 FLASH_HalfCycleAccessCmd function . . . . . . . . . . . . . . . . . . . . . . . . 149

9.2.3 FLASH_PrefetchBufferCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . 150

9.2.4 FLASH_Unlock function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

9.2.5 FLASH_Lock function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

9.2.6 FLASH_ErasePage function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

9.2.7 FLASH_EraseAllPages function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

9.2.8 FLASH_EraseOptionBytes function . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

9.2.9 FLASH_ProgramWord function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

9.2.10 FLASH_ProgramHalfWord function . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

9.2.11 FLASH_ProgramOptionByteData function . . . . . . . . . . . . . . . . . . . . . . 154

9.2.12 FLASH_EnableWriteProtection function . . . . . . . . . . . . . . . . . . . . . . . 155

9.2.13 FLASH_ReadOutProtection function . . . . . . . . . . . . . . . . . . . . . . . . . . 157

9.2.14 FLASH_UserOptionByteConfig function . . . . . . . . . . . . . . . . . . . . . . . 158

9.2.15 FLASH_GetUserOptionByte function . . . . . . . . . . . . . . . . . . . . . . . . . 160

9.2.16 FLASH_GetWriteProtectionOptionByte function . . . . . . . . . . . . . . . . . 160

9.2.17 FLASH_GetReadOutProtectionStatus function . . . . . . . . . . . . . . . . . . 161

9.2.18 FLASH_GetPrefetchBufferStatus function . . . . . . . . . . . . . . . . . . . . . . 161

9.2.19 FLASH_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

9.2.20 FLASH_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

9.2.21 FLASH_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

9.2.22 FLASH_GetStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

9.2.23 FLASH_WaitForLastOperation function . . . . . . . . . . . . . . . . . . . . . . . . 165


10 General purpose I/O (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

10.1 GPIO register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

10.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

10.2.1 GPIO_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

10.2.2 GPIO_AFIODeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

10.2.3 GPIO_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

GPIO_InitTypeDef structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

10.2.4 GPIO_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

10.2.5 GPIO_ReadInputDataBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

10.2.6 GPIO_ReadInputData function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

10.2.7 GPIO_ReadOutputDataBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

10.2.8 GPIO_ReadOutputData function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

10.2.9 GPIO_SetBits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

10.2.10 GPIO_ResetBits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

10.2.11 GPIO_WriteBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

10.2.12 GPIO_Write function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178

10.2.13 GPIO_PinLockConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

10.2.14 GPIO_EventOutputConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

10.2.15 GPIO_EventOutputCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

10.2.16 GPIO_PinRemapConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

10.2.17 GPIO_EXTILineConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182


11 Inter-integrated circuit (I2C) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

11.1 I2C register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

11.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186

11.2.1 I2C_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

11.2.2 I2C_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

I2C_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

11.2.3 I2C_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

11.2.4 I2C_Cmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

11.2.5 I2C_DMACmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

11.2.6 I2C_DMALastTransferCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . 192

11.2.7 I2C_GenerateSTART function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

11.2.8 I2C_GenerateSTOP function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

11.2.9 I2C_AcknowledgeConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

11.2.10 I2C_OwnAddress2Config function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

11.2.11 I2C_DualAddressCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

11.2.12 I2C_GeneralCallCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

11.2.13 I2C_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

11.2.14 I2C_SendData function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

11.2.15 I2C_ReceiveData function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

11.2.16 I2C_Send7bitAddress function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

11.2.17 I2C_ReadRegister function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

11.2.18 I2C_SoftwareResetCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

11.2.19 I2C_SMBusAlertConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

11.2.20 I2C_TransmitPEC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

11.2.21 I2C_PECPositionConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

11.2.22 I2C_CalculatePEC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

11.2.23 I2C_GetPEC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204

11.2.24 I2C_ARPCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204

11.2.25 I2C_StretchClockCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

11.2.26 I2C_FastModeDutyCycleConfig function . . . . . . . . . . . . . . . . . . . . . . . 205

11.2.27 I2C_GetLastEvent function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206

11.2.28 I2C_CheckEvent function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

11.2.29 I2C_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

11.2.30 I2C_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

11.2.31 I2C_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211

11.2.32 I2C_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212


12 Independent watchdog (IWDG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

12.1 IWDG register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

12.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

12.2.1 IWDG_WriteAccessCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

12.2.2 IWDG_SetPrescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

12.2.3 IWDG_SetReload function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

12.2.4 IWDG_ReloadCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

12.2.5 IWDG_Enable function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

12.2.6 IWDG_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218


13 Nested vectored interrupt controller (NVIC) . . . . . . . . . . . . . . . . . . . . 220

13.1 NVIC register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

13.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

13.2.1 NVIC_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

13.2.2 NVIC_SCBDeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

13.2.3 NVIC_PriorityGoupConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

13.2.4 NVIC_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

NVIC_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

13.2.5 NVIC_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

13.2.6 NVIC_SETPRIMASK function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

13.2.7 NVIC_RESETPRIMASK function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230

13.2.8 NVIC_SETFAULTMASK function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

13.2.9 NVIC_RESETFAULTMASK function . . . . . . . . . . . . . . . . . . . . . . . . . . 231

13.2.10 NVIC_BASEPRICONFIG function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

13.2.11 NVIC_GetBASEPRI function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232

13.2.12 NVIC_GetCurrentPendingIRQChannel function . . . . . . . . . . . . . . . . . 233

13.2.13 NVIC_GetIRQChannelPendingBitStatus function . . . . . . . . . . . . . . . . 233

13.2.14 NVIC_SetIRQChannelPendingBit function . . . . . . . . . . . . . . . . . . . . . 234

13.2.15 NVIC_ClearIRQChannelPendingBit function . . . . . . . . . . . . . . . . . . . . 234

13.2.16 NVIC_GetCurrentActiveHandler function . . . . . . . . . . . . . . . . . . . . . . . 235

13.2.17 NVIC_GetIRQChannelActiveBitStatus function . . . . . . . . . . . . . . . . . . 235

13.2.18 NVIC_GetCPUID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

13.2.19 NVIC_SetVectorTable function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

13.2.20 NVIC_GenerateSystemReset function . . . . . . . . . . . . . . . . . . . . . . . . 237

13.2.21 NVIC_GenerateCoreReset function . . . . . . . . . . . . . . . . . . . . . . . . . . 237

13.2.22 NVIC_SystemLPConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238

13.2.23 NVIC_SystemHandlerConfig function . . . . . . . . . . . . . . . . . . . . . . . . . 239

13.2.24 NVIC_SystemHandlerPriorityConfig function . . . . . . . . . . . . . . . . . . . 245

13.2.25 NVIC_GetSystemHandlerPendingBitStatus function . . . . . . . . . . . . . . 246

13.2.26 NVIC_SetSystemHandlerPendingBit function . . . . . . . . . . . . . . . . . . . 247

13.2.27 NVIC_ClearSystemHandlerPendingBit function . . . . . . . . . . . . . . . . . 248

13.2.28 NVIC_GetSystemHandlerActiveBitStatus function . . . . . . . . . . . . . . . 249

13.2.29 NVIC_GetFaultHandlerSources function . . . . . . . . . . . . . . . . . . . . . . . 250

13.2.30 NVIC_GetFaultAddress function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251


14 Power control (PWR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

14.1 PWR register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

14.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

14.2.1 PWR_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

14.2.2 PWR_BackupAccessCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

14.2.3 PWR_PVDCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

14.2.4 PWR_PVDLevelConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

14.2.5 PWR_WakeUpPinCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

14.2.6 PWR_EnterSTOPMode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

14.2.7 PWR_EnterSTANDBYMode function . . . . . . . . . . . . . . . . . . . . . . . . . . 257

14.2.8 PWR_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258

14.2.9 PWR_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259


15 Reset and clock control (RCC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

15.1 RCC register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

15.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261

15.2.1 RCC_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

15.2.2 RCC_HSEConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

15.2.3 RCC_WaitForHSEStartUp function . . . . . . . . . . . . . . . . . . . . . . . . . . . 264

15.2.4 RCC_AdjustHSICalibrationValue function . . . . . . . . . . . . . . . . . . . . . . 266

15.2.5 RCC_HSICmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266

15.2.6 RCC_PLLConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267

15.2.7 RCC_PLLCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268

15.2.8 RCC_SYSCLKConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

15.2.9 RCC_GetSYSCLKSource function . . . . . . . . . . . . . . . . . . . . . . . . . . . 270

15.2.10 RCC_HCLKConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

15.2.11 RCC_PCLK1Config function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272

15.2.12 RCC_PCLK2Config function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

15.2.13 RCC_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274

15.2.14 RCC_USBCLKConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

15.2.15 RCC_ADCCLKConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

15.2.16 RCC_LSEConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

15.2.17 RCC_LSICmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

15.2.18 RCC_RTCCLKConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

15.2.19 RCC_RTCCLKCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

15.2.20 RCC_GetClocksFreq function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

RCC_ClocksTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

15.2.21 RCC_AHBPeriphClockCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . 281

15.2.22 RCC_APB2PeriphClockCmd function . . . . . . . . . . . . . . . . . . . . . . . . . 282

15.2.23 RCC_APB1PeriphClockCmd function . . . . . . . . . . . . . . . . . . . . . . . . . 283

15.2.24 RCC_APB2PeriphResetCmd function . . . . . . . . . . . . . . . . . . . . . . . . . 284

15.2.25 RCC_APB1PeriphResetCmd function . . . . . . . . . . . . . . . . . . . . . . . . . 285

15.2.26 RCC_BackupResetCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

15.2.27 RCC_ClockSecuritySystemCmd function . . . . . . . . . . . . . . . . . . . . . . 286

15.2.28 RCC_MCOConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286

15.2.29 RCC_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

15.2.30 RCC_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

15.2.31 RCC_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

15.2.32 RCC_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290


16 Real-time clock (RTC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

16.1 RTC register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292

16.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294

16.2.1 RTC_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295

16.2.2 RTC_EnterConfigMode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

16.2.3 RTC_ExitConfigMode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296

16.2.4 RTC_GetCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

16.2.5 RTC_SetCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

16.2.6 RTC_SetPrescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298

16.2.7 RTC_SetAlarm function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298

16.2.8 RTC_GetDivider function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

16.2.9 RTC_WaitForLastTask function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299

16.2.10 RTC_WaitForSynchro function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

16.2.11 RTC_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300

16.2.12 RTC_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301

16.2.13 RTC_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302

16.2.14 RTC_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302


17 Serial peripheral interface (SPI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

17.1 SPI register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

17.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

17.2.1 SPI_I2S_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306

17.2.2 SPI_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306

SPI_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307

17.2.3 I2S_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

17.2.4 SPI_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312

17.2.5 I2S_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313

17.2.6 SPI_Cmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314

17.2.7 I2S_Cmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314

17.2.8 SPI_I2S_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

17.2.9 SPI_I2S_DMACmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316

17.2.10 SPI_I2S_SendData function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

17.2.11 SPI_I2S_ReceiveData function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

17.2.12 SPI_NSSInternalSoftwareConfig function . . . . . . . . . . . . . . . . . . . . . . 318

17.2.13 SPI_SSOutputCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

17.2.14 SPI_DataSizeConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

17.2.15 SPI_TransmitCRC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320

17.2.16 SPI_CalculateCRC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

17.2.17 SPI_GetCRC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321

17.2.18 SPI_GetCRCPolynomial function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322

17.2.19 SPI_BiDirectionalLineConfig function . . . . . . . . . . . . . . . . . . . . . . . . . 323

17.2.20 SPI_I2S_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324

17.2.21 SPI_I2S_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325

17.2.22 SPI_I2S_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326

17.2.23 SPI_I2S_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . 327


18 Cortex system timer (SysTick) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

18.1 SysTick register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328

18.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

18.2.1 SysTick_CLKSourceConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . 329

18.2.2 SysTick_SetReload function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330

18.2.3 SysTick_CounterCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

18.2.4 SysTick_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

18.2.5 SysTick_GetCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332

18.2.6 SysTick_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333


19 Advanced-control timer, general-purpose timer and

basic timer (TIM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

19.1 TIM register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334

19.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338

19.2.1 TIM_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341

19.2.2 TIM_TimeBaseInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342

TIM_TimeBaseInitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342

19.2.3 TIM_OC1Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

TIM_OCInitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

19.2.4 TIM_OC2Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347

19.2.5 TIM_OC3Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348

19.2.6 TIM_OC4Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

19.2.7 TIM_ICInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

TIM_ICInitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350

19.2.8 TIM_PWMIConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352

19.2.9 TIM_BDTRConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

TIM_BDTRInitStruct structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

19.2.10 TIM_TimeBaseStructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355

19.2.11 TIM_OCStructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356

19.2.12 TIM_ICStructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357

19.2.13 TIM_BDTRStructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358

19.2.14 TIM_Cmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

19.2.15 TIM_CtrlPWMOutputs function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

19.2.16 TIM_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360

19.2.17 TIM_GenerateEvent function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361

19.2.18 TIM_DMAConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362

19.2.19 TIM_DMACmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364

19.2.20 TIM_InternalClockConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365

19.2.21 TIM_ITRxExternalClockConfig function . . . . . . . . . . . . . . . . . . . . . . . . 366

19.2.22 TIM_TIxExternalClockConfig function . . . . . . . . . . . . . . . . . . . . . . . . . 367

19.2.23 TIM_ETRClockMode1Config function . . . . . . . . . . . . . . . . . . . . . . . . . 368

19.2.24 TIM_ETRClockMode2Config function . . . . . . . . . . . . . . . . . . . . . . . . . 369

19.2.25 TIM_ETRConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370

19.2.26 TIM_PrescalerConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371

19.2.27 TIM_CounterModeConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

19.2.28 TIM_SelectInputTrigger function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372

19.2.29 TIM_EncoderInterfaceConfig function . . . . . . . . . . . . . . . . . . . . . . . . . 373

19.2.30 TIM_ForcedOC1Config function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374

19.2.31 TIM_ForcedOC2Config function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

19.2.32 TIM_ForcedOC3Config function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

19.2.33 TIM_ForcedOC4Config function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376

19.2.34 TIM_ARRPreloadConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376

19.2.35 TIM_SelectCOM function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

19.2.36 TIM_SelectCCDMA function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377

19.2.37 TIM_CCPreloadControl function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378

19.2.38 TIM_OC1PreloadConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378

19.2.39 TIM_OC2PreloadConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

19.2.40 TIM_OC3PreloadConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

19.2.41 TIM_OC4PreloadConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380

19.2.42 TIM_OC1FastConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381

19.2.43 TIM_OC2FastConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382

19.2.44 TIM_OC3FastConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382

19.2.45 TIM_OC4FastConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

19.2.46 TIM_ClearOC1Ref . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

19.2.47 TIM_ClearOC2Ref . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384

19.2.48 TIM_ClearOC3Ref . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385

19.2.49 TIM_ClearOC4Ref . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385

19.2.50 TIM_OC1PolarityConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386

19.2.51 TIM_OC1NPolarityConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387

19.2.52 TIM_OC2PolarityConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387

19.2.53 TIM_OC2NPolarityConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388

19.2.54 TIM_OC3PolarityConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388

19.2.55 TIM_OC3NPolarityConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389

19.2.56 TIM_OC4PolarityConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389

19.2.57 TIM_CCxCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390

19.2.58 TIM_CCxNCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390

19.2.59 TIM_SelectOCxM function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391

19.2.60 TIM_UpdateDisableConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . 392

19.2.61 TIM_UpdateRequestConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . 392

19.2.62 TIM_SelectHallSensor function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

19.2.63 TIM_SelectOnePulseMode function . . . . . . . . . . . . . . . . . . . . . . . . . . 394

19.2.64 TIM_SelectOutputTrigger function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395

19.2.65 TIM_SelectSlaveMode function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396

19.2.66 TIM_SelectMasterSlaveMode function . . . . . . . . . . . . . . . . . . . . . . . . 397

19.2.67 TIM_SetCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397

19.2.68 TIM_SetAutoreload function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

19.2.69 TIM_SetCompare1 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398

19.2.70 TIM_SetCompare2 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399

19.2.71 TIM_SetCompare3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399

19.2.72 TIM_SetCompare4 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400

19.2.73 TIM_SetIC1Prescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400

19.2.74 TIM_SetIC2Prescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401

19.2.75 TIM_SetIC3Prescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

19.2.76 TIM_SetIC4Prescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

19.2.77 TIM_SetClockDivision function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403

19.2.78 TIM_GetCapture1 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403

19.2.79 TIM_GetCapture2 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404

19.2.80 TIM_GetCapture3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404

19.2.81 TIM_GetCapture4 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405

19.2.82 TIM_GetCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405

19.2.83 TIM_GetPrescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406

19.2.84 TIM_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406

19.2.85 TIM_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408

19.2.86 TIM_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408

19.2.87 TIM_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409


20 Universal synchronous asynchronous receiver

transmitter (USART) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410

20.1 USART register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410

20.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

20.2.1 USART_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

20.2.2 USART_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414

USART_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

20.2.3 USART_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417

20.2.4 USART_ClockInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417

USART_ClockInitTypeDef structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418

20.2.5 USART_ClockStructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420

20.2.6 USART_Cmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421

20.2.7 USART_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421

20.2.8 USART_DMACmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422

20.2.9 USART_SetAddress function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423

20.2.10 USART_WakeUpConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424

20.2.11 USART_ReceiverWakeUpCmd function . . . . . . . . . . . . . . . . . . . . . . . 425

20.2.12 USART_LINBreakDetectLengthConfig function . . . . . . . . . . . . . . . . . 425

20.2.13 USART_LINCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426

20.2.14 USART_SendData function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427

20.2.15 USART_ReceiveData function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427

20.2.16 USART_SendBreak function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428

20.2.17 USART_SetGuardTime function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428

20.2.18 USART_SetPrescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

20.2.19 USART_SmartCardCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

20.2.20 USART_SmartCardNACKCmd function . . . . . . . . . . . . . . . . . . . . . . . 430

20.2.21 USART_HalfDuplexCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430

20.2.22 USART_IrDAConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431

20.2.23 USART_IrDACmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432

20.2.24 USART_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432

20.2.25 USART_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433

20.2.26 USART_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434

20.2.27 USART_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . 435


21 Window watchdog (WWDG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

21.1 WWDG registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

21.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438

21.2.1 WWDG_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438

21.2.2 WWDG_SetPrescaler function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439

21.2.3 WWDG_SetWindowValue function . . . . . . . . . . . . . . . . . . . . . . . . . . . 440

21.2.4 WWDG_EnableIT function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440

21.2.5 WWDG_SetCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441

21.2.6 WWDG_Enable function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441

21.2.7 WWDG_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442

21.2.8 WWDG_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442


22 Digital/analog converter (DAC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

22.1 DAC register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

22.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445

22.2.1 DAC_DeInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445

22.2.2 DAC_Init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446

DAC_Channel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446

DAC_InitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446

22.2.3 DAC_StructInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449

22.2.4 DAC_Cmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450

22.2.5 DAC_DMACmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450

22.2.6 DAC_SoftwareTriggerCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

22.2.7 DAC_DualSoftwareTriggerCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

22.2.8 DAC_WaveGenerationCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452

22.2.9 DAC_SetChannel1Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453

22.2.10 DAC_SetChannel2Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454

22.2.11 DAC_SetDualChannelData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

22.2.12 DAC_GetDataOutputValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456


23 Flexible static memory controller (FSMC) . . . . . . . . . . . . . . . . . . . . . 457

23.1 FSMC register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457

23.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460

23.2.1 FSMC_NORSRAMDeInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 461

23.2.2 FSMC_NANDDeInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462

23.2.3 FSMC_PCCARDDeInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

23.2.4 FSMC_NORSRAMInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

FSMC_NORSRAMTimingInitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464

FSMC_NORSRAMInitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465

23.2.5 FSMC_NANDInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470

FSMC_NAND_PCCARDTimingInitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470

FSMC_NANDInitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471

23.2.6 FSMC_PCCARDInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474

FSMC_NAND_PCCARDTimingInitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474

FSMC_PCCARDInitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475

23.2.7 FSMC_NORSRAMStructInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477

23.2.8 FSMC_NANDStructInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478

23.2.9 FSMC_PCCARDStructInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479

23.2.10 FSMC_NORSRAMCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

23.2.11 FSMC_NANDCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

23.2.12 FSMC_PCCARDCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482

23.2.13 FSMC_PCCARDCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482

23.2.14 FSMC_NANDECCCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483

23.2.15 FSMC_ITConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483

23.2.16 FSMC_GetFlagStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484

23.2.17 FSMC_ClearFlag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485

23.2.18 FSMC_GetITStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486

23.2.19 FSMC_ClearITPendingBit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486


24 SDIO interface (SDIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

24.1 SDIO register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

24.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489

24.2.1 SDIO_DeInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490

24.2.2 SDIO_Init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490

SDIO_InitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491

24.2.3 SDIO_StructInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493

24.2.4 SDIO_ClockCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494

24.2.5 SDIO_SetPowerState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494

24.2.6 SDIO_GetPowerState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

24.2.7 SDIO_ITConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495

24.2.8 SDIO_DMACmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497

24.2.9 SDIO_SendCommand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497

SDIO_CmdInitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498

24.2.10 SDIO_CmdStructInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499

24.2.11 SDIO_GetCommandResponse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500

24.2.12 SDIO_GetResponse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500

24.2.13 SDIO_DataConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501

SDIO_DataInitTypeDef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 501

24.2.14 SDIO_DataStructInit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503

24.2.15 SDIO_GetDataCounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504

24.2.16 SDIO_ReadData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505

24.2.17 SDIO_WriteData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505

24.2.18 SDIO_GetFIFOCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506

24.2.19 SDIO_StartSDIOReadWait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506

24.2.20 SDIO_StopSDIOReadWait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507

24.2.21 SDIO_SetSDIOReadWaitMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507

24.2.22 SDIO_SetSDIOOperation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508

24.2.23 SDIO_SendSDIOSuspendCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508

24.2.24 SDIO_CommandCompletionCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509

24.2.25 SDIO_CEATAITCmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509

24.2.26 SDIO_SendCEATACmd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510

24.2.27 SDIO_GetFlagStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510

24.2.28 SDIO_ClearFlag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512

24.2.29 SDIO_GetITStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513

24.2.30 SDIO_ClearITPendingBit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513


25 Debug MCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515

25.1 DBGMCU register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515

25.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516

25.2.1 DBGMCU_GetREVID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516

25.2.2 DBGMCU_GetDEVID function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517

25.2.3 DBGMCU_Config function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517


26 CRC calculation unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519

26.1 CRC register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519

26.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520

26.2.1 CRC_ResetDR function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520

26.2.2 CRC_CalcCRC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521

26.3 CRC_CalcBlockCRC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521

26.3.1 CRC_GetCRC function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522

26.3.2 CRC_SetIDRegister function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522

26.3.3 CRC_GetIDRegister function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

진행방식을 바꾼다...  (0) 2013.06.23
함수표 참조 설명  (0) 2013.06.23
정확한 1초 Delay 구현  (0) 2013.06.23
RCC_GetClockFreq  (0) 2013.06.23
Clock Control  (0) 2013.06.23
Posted by 십자성군

Processor mode

1. Thread mode

:application software 수행할때 사용

:reset 시, exception 종료시 돌아오는 기본모드 

2. Handler mode

:exceptions을 handle할 때 사용.


여기서는 exception과 외부 IRQ(Interrupt Request)를 다룬다.


레퍼런스 메뉴얼에 exception 관련 52, 53번 table을 참조한다.


synchronous는 동기적인 것이고 asynchronous는 비동기적인 것이다.


p304를 보면 여기서 다루는것은 3가지로

SysTick(System Tick Timer), NVIC(Nested vectored interrupt controller), SCB(System Control Block)이다


1.NVIC Vector Table 설정

참조함수 : NVIC_SetVectorTable


NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x0);에서


#define NVIC_VectTab_RAM             ((uint32_t)0x20000000)

#define NVIC_VectTab_FLASH           ((uint32_t)0x08000000)

로 되어있다.


SCB->VTOR(Vector table offset register)

설정되는 값이 RAM영역 이거나 FLASH 영역 이라는데 위의 NVIC 두개를 말하는 것이다


2.SysTick Configuration

참조함수 : RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)

  static __INLINE uint32_t SysTick_Config(uint32_t ticks)    위치 : core_cm3.h(C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.0\arm\CMSIS\Include)



SysTick_Type 의 네개의 변수가 있다.

CTRL, LOAD, VAL, CALIB.

LOAD(SysTick reload value register) : 매 클럭마다 이 값이 1씩 감소한다. 예를들어 99를 설정하면 100클럭마다 인터럽트가 발생한다.


VAL(SysTick current value register)

현재 count 값이 저장되어 있는 곳. 0을 넣어두고 시작.


CTRL(SysTick control and status register)

SysTick enable 관련

CLKSOURCE, ENABLE, TICKINT를 설정하여 동작방식을 설정한다.


NVIC_SetPriority

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

함수표 참조 설명  (0) 2013.06.23
함수표  (0) 2013.06.23
RCC_GetClockFreq  (0) 2013.06.23
Clock Control  (0) 2013.06.23
Get Character  (0) 2013.06.14
Posted by 십자성군

RCC_GetClockFreq함수 역시 이미 구현되어 있다. 그 구조와 원리만 간단하게 이해하도록 하자.


...설명할게 없다. 그냥 사용하면 되는데다 테이블에서 좌표값을 읽어온다.

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

함수표  (0) 2013.06.23
정확한 1초 Delay 구현  (0) 2013.06.23
Clock Control  (0) 2013.06.23
Get Character  (0) 2013.06.14
당분간 정지  (0) 2013.06.14
Posted by 십자성군



대상 : SetSysClockTo72


참조 : RCC_CR


시스템 클럭을 사용하는 방법

1.HSI를 그대로 사용

2.HSE를 그대로 사용

3.PLL을 거쳐서 생성된 클럭을 사용


PLL의 사용에 HSI 또는 HSE를 사용할 수 있으나 정확도의 문제로 향후 USB를 사용하기 위해 외부 클럭 사용을 추천

현재 나의 모듈의 외부클럭은 8MHz 이기 때문에 72MHz를 구하기 위하여 9를 곱해야 한다.


1. Enable HSE(High Speed External)


RCC_CR_HSEON

:HSEON을 1로 만들어 HSE를 Enable로 만든다.(HSE Oscillator ON)


RCC_CR_HSERDY

:HSE oscillator가 사용 가능해졌는지 확인(하드웨어에 의해서 1로 Set)


HSEStartUp_TimeOut

:HSERDY에 대한 time out




2.Flash access Latency


FLASH_ACR_LATENCY_2


3.RCC_CFGR(clock ConFiGuration Register) 

HCLK

PCLK1

PCLK2

ADCCLK 의 4개 클럭이 있다.

주의할 점은 PCLK1의 Max Clock은 36MHz라는것. 따라서 HCLK를 72MHz로 설정한다면 PCLK1은 HCLK/2로 하여 36MHz나 그 이하로 만들어야 한다.


.PLL설정

PLL 소스로 HSE를 사용하면서 곱할 값 설정하자.

PLLMUL, PLLSRC를 설정한다.


PLLSRC : RCC_CFGR_PLLSRC_HSE

PLLMUL : RCC_CFGR_PLLMULL9



PLL ON

PLLON    : PLL enable

PLLRDY  : PLL clock ready flag


SW : System clock switch    (HSI,HSE,PLL중 무엇을 System Clock으로 사용할 것인가 설정)

SWS : System clock switch status    (Switch Status... 플래그같은거?)


위의 설정을 다루어 모듈의 동작은 72MHz로 맞춰진다

이후 USART_Init의 apbclock를 72000000 으로 교체하여 클럭에 맞춘 통신도 가능할 것이다.

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

정확한 1초 Delay 구현  (0) 2013.06.23
RCC_GetClockFreq  (0) 2013.06.23
Get Character  (0) 2013.06.14
당분간 정지  (0) 2013.06.14
UART_ Hello_Wolrd 찍기_2  (0) 2013.06.08
Posted by 십자성군