使用的主芯片是MSP430F6721,使用RTC功能,AUXVCC引脚该怎么连接,程序该怎么实现呢?
参考了TI官方论坛的资料
官方论坛如下:
如题。数据手册和技术手册通篇只讲过进入LPM3.5模式,能保持RTC计时。如果不配置任何工作模式,就是直接断电,AUXVCC3脚锂电供电,还会继续计时吗?总觉得手册讲的不清楚,不像别的单片机手册关于RTC的,只归备用供电部分管,讲的很清楚。
这款单片机的RTC寄存器分为2类:一类控制型的,一类时间信息型的。这两类寄存器在有的单片机里都是备用供电管理,MCU复位还是掉电,只有备用供电正常,就继续计时。但430f672x不一样,控制型的受MCU控制,如POR复位,值回到初值。不知讲的对不对???
当VCC掉电的时候,为了保证RTC继续工作,可以按照如下设置来实现:
连接电源到主电源DVcc,Avcc,这里为3.3v,连接备用电池到Auxvcc1,Auxvcc3,这里为3.0v锂电池,将不用的备用电源引脚Auxvcc2接地,并在固件代码中关闭它。如下是供电电源切换并关闭Auxvcc2:
AUX0MD=0;AUX1MD=0;AUX2MD=1;
设置下一次选择的供电电源:
AUX0OK=1;AUX1OK=1;AUX2OK=0;AUX2PRIO=0;
在程序中当检测到切换到AUXVCC1时,保存当前工作进入LPM3.5模式,直到VCC电源恢复。检测VCC是否恢复使用端口1或者2的中断功能检测。
下面是RTC_C 在 LPM3.5 模式运行的代码例程,开发环境是CCS:
C:TIccsv5ccs_basemsp430MSP430ware_1_30_00_15examplesdevices5xx_6xxMSP430F673x Code ExamplesCMSP430F673X_RTC_02.c
官方论坛给的资料太少了,也不知道该怎么实现,谁能够提供一些例程呀。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
#include <msp430.h>
int main (void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
if (SYSRSTIV == SYSRSTIV_LPM5WU)
{
// When woken up from LPM3.5, reinit since LPMx.5 will cause a BOR.
PMMCTL0_H = PMMPW_H; // open PMM
PM5CTL0 &= ~LOCKIO; // Clear LOCKBAK and enable ports
PMMCTL0_H = 0x00; // close PMM
P1DIR |= BIT0; // Configure P1.0 as GPIO output
// Reconfigure RTC to read RTC registers
RTCCTL0_H = RTCKEY_H; // Unlock RTC_C module
RTCCTL1 |= RTCBCD | RTCHOLD; // BCD mode, RTC hold
RTCCTL1 &= ~(RTCHOLD); // Start RTC calendar mode
RTCCTL0_H = 0; // Lock RTC_C module
// If woken up at noon, set LED and stay loop there
if((RTCHOUR == 0x12)&&(RTCMIN == 0x00)&&(RTCSEC == 0x00))
{
P1OUT |= BIT0; // Set P1.0 on
while(1);
}
// If values do not match, blink LED fast
else
{
while(1) // continuous loop
{
P1OUT ^= BIT0; // XOR P1.0
__delay_cycles(20000); // Delay
}
}
}
// GPIO Port Configuration for lowest power configuration
P1OUT = 0x00;P2OUT = 0x00;P3OUT = 0x00;P4OUT = 0x00;P5OUT = 0x00;P6OUT = 0x00;
P7OUT = 0x00;P8OUT = 0x00;P9OUT = 0x00;PJOUT = 0x00;
P1DIR = 0xFF;P2DIR = 0xFF;P3DIR = 0xFF;P4DIR = 0xFF;P5DIR = 0xFF;P6DIR = 0xFF;
P7DIR = 0xFF;P8DIR = 0xFF;P9DIR = 0xFF;PJDIR = 0xFF;
// 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
// Configure RTC_C
RTCCTL0_H = RTCKEY_H; // Unlock RTC_C module
RTCCTL0_L |= RTCTEVIE; // Enable RTC time event interrupt
RTCCTL1 |= RTCBCD | RTCTEV_0 | RTCHOLD; // BCD mode, RTC hold, Set RTCTEV for 1 minute alarm
// event interrupt
RTCYEAR = 0x2011; // Year = 0x2011
RTCMON = 0x10; // Month = 0x10 = October
RTCDAY = 0x07; // Day = 0x07 = 7th
RTCDOW = 0x05; // Day of week = 0x05 = Friday
RTCHOUR = 0x11; // Hour = 0x11
RTCMIN = 0x59; // Minute = 0x59
RTCSEC = 0x45; // Seconds = 0x45
RTCCTL1 &= ~(RTCHOLD); // Start RTC calendar mode
RTCCTL0_H = 0; // Lock RTC_C module
// Enter LPM3.5
UCSCTL6 |= XT1OFF; // Turn off clock for LPMx.5 operation. ACLK will still
// remain active
PMMCTL0_H = PMMPW_H; // Open PMM Registers for write
PMMCTL0_L |= PMMREGOFF; // and set PMMREGOFF
__bis_SR_register(LPM4_bits | GIE); // Enter LPM3.5 mode with interrupts enabled
__no_operation();
// Code should NOT get here. This means that LPM3.5 was not properly entered.
// Ensure that an external power supply was ued. Or else JTAG will put the CPU
// in LPM0 mode.
// Stop the RTC
RTCCTL0_H = RTCKEY_H; // Unlock RTC_C module
RTCCTL1 |= RTCHOLD; // RTC hold
RTCCTL0_H = 0; // Lock RTC_C module
// Blink LED slowly if LPM3.5 not entered properly
while(1)
{
P1OUT ^= BIT0; // XOR P1.0
__delay_cycles(500000); // Delay
}
}
#pragma vector=RTC_VECTOR
__interrupt void rtc_isr(void)
{
switch (__even_in_range(RTCIV, 16))
{
case RTCIV_NONE: // No interrupts
break;
case RTCIV_RTCOFIFG: // RTCOFIFG
break;
case RTCIV_RTCRDYIFG: // RTCRDYIFG
break;
case RTCIV_RTCTEVIFG: // RTCEVIFG
PMMCTL0_H = PMMPW_H; // open PMM
PM5CTL0 &= ~LOCKIO; // Clear LOCKBAK and enable ports
PMMCTL0_H = 0x00; // close PMM
__bic_SR_register_on_exit(LPM4_bits); // Exit LPM4.5
__no_operation();
break;
case RTCIV_RTCAIFG: // RTCAIFG
break;
case RTCIV_RT0PSIFG: // RT0PSIFG
break;
case RTCIV_RT1PSIFG: // RT1PSIFG
break;
case 14: break; // Reserved
case 16: break; // Reserved
default: break;
}
}
关于这个例程有一些疑问
1,进入的是LPM3.5模式,RTC中断中为什么退出LPM4.5模式
2,什么情况下进入 if (SYSRSTIV == SYSRSTIV_LPM5WU) 语句,是断电吗
3,在 if (SYSRSTIV == SYSRSTIV_LPM5WU)语句中,并没有对RTC做中断设置,以前的RTC设置的
应该已经改变了吧,这样RTC还能进中断吗
4,此程序掉电后,再重新上电,RTC时钟是否丢失
一周热门 更多>