藍橋杯嵌入式 RTC

2021-10-01 19:50:28 字數 1174 閱讀 3070

bkp裡是關於備份暫存器的庫函式,pwr裡是關於電源管理的庫函式

#ifndef __rtc_h

#define __rtc_h

#include "stm32f10x.h"

void rtc_init(u8 hh,u8 mm,u8 ss);

#endif

#include "rtc.h"

void rtc_init(u8 hh,u8 mm,u8 ss)

我們要在

pwr中使能

backup

暫存器。這一步是非常關鍵的,如果缺少了這一步,那麼後面的

rtc讀寫將會失敗

我們藍橋杯嵌入式板子,只能使用

lsi時鐘源

第一步先把

lsi時鐘使能,第二部把

rtc的時鐘選擇為

lsi作為時鐘源,第三部使能

rtc時鐘

lsi

時鐘頻率大約

40khz

,rtc

需要1hz

的時鐘,因此需要

40000-1

分頻

#include "stm32f10x.h"

#include "lcd.h"

#include "rtc.h"

#include "stdio.h"

u32 timingdelay = 0;

u8 rtc_flag;

u8 string[20];

void delay_ms(u32 ntime);

//main body

int main(void) }}

//void delay_ms(u32 ntime)

extern u8 rtc_flag;

void rtc_irqhandler(void)

}}

stm32韌體庫v3.5\stm32f10x_stdperiph_lib_v3.5.0\project\stm32f10x_stdperiph_examples\rtc\lsi_cali

藍橋杯嵌入式 USART

乙個是串列埠 1 pa9,pa10 乙個是串列埠 2 pa2,pa3 我們的藍橋杯嵌入式開發板並不能直接使用串列埠 1rxbuf 是用來儲存串列埠的接收資料的,rxover 為接收串列埠結束標誌位,rxcunt 為串列埠接收計數值 ifndef usart h define usart h incl...

藍橋杯嵌入式 LCD

include stm32f10x.h include lcd.h include stdio.h u8 string 20 u8 temp 30 float ao 3.81 u32 timingdelay 0 void delay ms u32 ntime main body int main v...

藍橋杯嵌入式坑

1 float adc value 0 adc value adc getconversionvalue adc1 3.3f 4096 adc value必須是float不然就是0,特別鬼畜 2 蜂鳴器是pb4,adc是pb0 gpio pinremapconfig gpio remap swj n...