1. to 2楼:那段代码有。程序一样。第一批板时程序可用。 2. to 3楼:测了,有波形,但是程序用外晶时,死等了 3. to 4楼:换了晶振不起作用. 用的芯片为stm32f103c8 48脚的。程序应该没问题,以下为配置程序 4. 我想问问,芯片不会有问题吧?但是这批我这里都这样。从万里拿的 void RTC_Configuration(void) { /* Enable PWR and BKP clocks */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
/* Allow access to BKP Domain */ PWR_BackupAccessCmd(ENABLE);
/* Reset Backup Domain */ BKP_DeInit();
#ifdef RTCClockSource_LSI /* Enable LSI */ RCC_LSICmd(ENABLE); /* Wait till LSI is ready */ while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) { }
/* Select LSI as RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); #elif defined RTCClockSource_LSE /* Enable LSE */ RCC_LSEConfig(RCC_LSE_ON); /* Wait till LSE is ready */ while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) { }
/* Select LSE as RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); #endif
/* Enable RTC Clock */ RCC_RTCCLKCmd(ENABLE);
#ifdef RTCClockOutput_Enable /* Disable the Tamper Pin */ BKP_TamperPinCmd(DISABLE); /* To output RTCCLK/64 on Tamper pin, the tamper functionality must be disabled */
Example description =================== This example demonstrates and explains how to use the RTC peripheral. As an application example, it demonstrates how to setup the RTC peripheral, in terms of prescaler and interrupts, to be used to keep time and to generate Second interrupt.
The Low Speed External (LSE) clock is used as RTC clock source. The RTC clock can be output on the Tamper pin (PC.13). To enable this functionality, uncomment the corresponding line: #define RTCClockOutput_Enable in the main.c file.
The RTC is in the backup (BKP) domain, still powered by VBAT when VDD is switched off, so the RTC configuration is not lost if a battery is connected to the VBAT pin. A key value is written in backup data register1 (BKP_DR1) to indicate if the RTC is already configured.