⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtc.c

📁 STM32F RFID通讯源代码(支持双向发送接收)
💻 C
字号:
// ADC.c
#include "stm32f10x_lib.h"
#include "rtc.h"
#include "arm_comm.h"
#include "includes.h"

extern GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;

void RTCInit(void) {

  // Led PC12 as output
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init (GPIOC, &GPIO_InitStructure);

  // Clock for pheriphery
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE);

  // CK_RTC clock selection
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

  // Allow access to BKP Domain
  PWR_BackupAccessCmd(ENABLE);

  // Reset Backup Domain
  BKP_DeInit();

  // Enable the LSE OSC
  RCC_LSEConfig(RCC_LSE_ON);

  // Disable the LSI OSC
  RCC_LSICmd(DISABLE);

  // Select the RTC Clock Source
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);

  // Enable the RTC Clock
  RCC_RTCCLKCmd(ENABLE);

  // Wait for RTC registers synchronization
  RTC_WaitForSynchro();

  // Wait until last write operation on RTC registers has finished
  RTC_WaitForLastTask();

  // Enable the RTC overflow interrupt
  RTC_ITConfig(RTC_IT_SEC, ENABLE);

  //Set 32768 prescaler - for one second interupt
  RTC_SetPrescaler(0x7FFF);

  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

  // Configure one bit for preemption priority
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

  // Enable the RTC Interrupt
  NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQChannel;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

  // Enable interrupts
  __enable_interrupt();

}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -