1. 在使用 TI MSP430F6733 单片机时 RTC_C 寄存器 不能赋值!
下面是TI 提供官方RTC 例程:
#include <msp430.h>
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WTD
// Initialize LFXT1
UCSCTL6 &= ~(XT1OFF); // Enable XT1
UCSCTL6 |= XCAP_3; // Internal load cap
// Loop until XT1, XT2 & DCO fault flag is cleared
do
{
UCSCTL7 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
} while (SFRIFG1 & OFIFG); // Test oscillator fault flag
P1OUT &= ~BIT0; // Clear P1.0 output
P1DIR |= BIT0; // Set P1.0 as output
// Configure RTC_C
RTCCTL0_H = RTCKEY_H; // Unlock RTC_C module 问题1: RTCCTL0_H 寄存器写入0xA5不能写入
RTCCTL0_L |= RTCTEVIE | RTCAIE | RTCRDYIE; // Enable RTC time event, alarm event,
// read ready interrupt
RTCCTL1 |= RTCBCD | RTCHOLD; // RTC enable BCD mode, RTC hold
RTCYEAR = 0x2011; // Year = 0x2011 = 2011 问题2: 寄存器写入0x2011不能写入
RTCMON = 0x12; // Month = 0x12 = December 问题3: 寄存器写入0x12不能写入
RTCDAY = 0x05; // Day = 0x05 = 5th 问题4: 寄存器写入0x05不能写入
RTCDOW = 0x03; // Day of week = 0x03 = Wednesday 问题5: 寄存器写入0x03不能写入
RTCHOUR = 0x24; // Hour = 0x12 问题6: 寄存器写入0x24不能写入
RTCMIN = 0x59; // Minute = 0x57 问题7: 寄存器写入0x59不能写入
RTCSEC = 0x55; // Seconds = 0x36 问题8: 寄存器写入0x55不能写入
RTCADOWDAY = 0x3; // RTC Day of week alarm = 0x2 问题1:
RTCADAY = 0x22; // RTC Day Alarm = 0x22 问题1:
RTCAHOUR = 0x23; // RTC Hour Alarm
RTCAMIN = 0x45; // RTC Minute Alarm
RTCCTL1 &= ~(RTCHOLD); // Start RTC calendar mode
RTCCTL0_H = 0; // Lock RTC_C module
__bis_SR_register(LPM3_bits | GIE); // Enter LPM3 w/ interrupts
// enabled
__no_operation();
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>