RTC与MSP430 [英] RTC with msp430

查看:333
本文介绍了RTC与MSP430的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前也问过这个问题,但是我觉得这个时候我可以问一些更清晰。

I have asked this question before, but I think this time I can ask with some more clarity.

以下是我的RTC测试code。我使用msp430f5418与IAR EW 5。

The below is my RTC Test code. I am using msp430f5418 with IAR EW 5.

我的问题是经过一些时间的分钟中断是比预期提前到来(我们15分钟多的测试)。

My problem is after some time (we tested with 15 minutes and more) the minutes interrupt is coming earlier than expected.

也就是说,在第一时间准确地在60秒后和15分钟分钟后中断来自第45秒的本身。

ie, On first time, after exactly 60 seconds and after 15 minutes the minute interrupt comes on 45th seconds itself.

为什么会这样呢?我们正在使用由TI为RTC提供的库注册操作。

Why is it so? We are using the library provided by TI for RTC register manipulation.

谁能告诉我为什么会这样?

Can anybody tell me why is it so??

时它与code或图书馆的不当使用或者与硬件本身??

Is it the problem with the code or with the improper usage of library or with the hardware itself??

在此先感谢...

#include <msp430.h>
#define RTC_VALID_READ_MAX_WAIT  500U
int main()
{
    WDTCTL = WDTPW + WDTHOLD;
    RTCCTL01 = RTCMODE + RTCTEVIE + RTCTEV_0;
    RTCCTL01 |= RTCHOLD;
    /* Calling the routines in the workaround assembly module supplied by TI */
    SetRTCYEAR (2011U);
    SetRTCMON (6U);
    SetRTCDOW (3U);
    SetRTCDAY (4U);
    SetRTCHOUR (23U);
    SetRTCMIN (0U);
    SetRTCSEC (0U);
    RTCCTL01 &= ~RTCHOLD;
    __enable_interrupt();
    while(1)
    {
    }
}

#pragma vector=RTC_VECTOR
__interrupt void handle_rtc_interrupt(void)
{
    switch(RTCIV)
    {
        case 2U:  /* RTC one second Ready Event for valid read */
        {
            int wait_counter = 0U;
            while (!(RTCCTL01&RTCRDY)) /* Wait for RTCRDY to go high, so read will be valid. */
            {
                wait_counter++;
                if (wait_counter > RTC_VALID_READ_MAX_WAIT)
                {
                    break;
                }
            }
            if (wait_counter<=RTC_VALID_READ_MAX_WAIT)
            {
                volatile int min = RTCMIN;
                volatile int sec = RTCSEC;
            }
            RTCCTL01 |= RTCHOLD;
            RTCCTL01 &= ~RTCRDYIE;
            RTCCTL01 &= ~RTCHOLD;
            break;
        }
        case 4U:        /* RTC Minute Interval Event */
        {
            RTCCTL01 |= RTCHOLD;
            RTCCTL01 |= RTCRDYIE;  /* Enable Ready Flag Interrupt */
            RTCCTL01 &= ~RTCHOLD;
            break;
        }
        default:
        {
            break;
        }
    }
}

推荐答案

恐怕我不能帮你调试code,但我在5418放弃了对RTC,因为我是有在不断的失败硬件。这是早在2008年,当我有原型,并第一个生产硅。我不认为RTC错误已在标准(非A)级部分已全面制定了即使是现在。因为我有在任何生产5418硅(任何面具转/勘误级)运行,并从F2418和F149处理器被迁移,就是我已经有了一个柔软的RTC,只是又回到了这一点。在处理和功耗开销是最小的。

I am afraid that I cannot help you with debugging the code but I gave up on the RTC in the 5418 as I was having continuous failures in the hardware. This was back in 2008 when I had prototype and first production silicon. I do not think that the RTC bugs have been fully worked out even now in the standard (non A) grade parts. As I have to run on any 5418 production silicon (any mask rev/errata level) and was migrating from the F2418 and F149 processor,s I already had a soft RTC and just went back to that. The overhead in processing and power consumption was minimal.

这篇关于RTC与MSP430的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆