Microchip
直播中

李凯生

8年用户 207经验值
私信 关注
[问答]

RTCC无增量PIC16F19186

,BTW:)我试着编写这个PIC的内部模块RTCC,但是我没有得到秒寄存器增量!这就像不工作,为什么?这是我的代码:这个代码来自MCC,我应该显示增量秒,但它不工作感谢

以上来自于百度翻译


      以下为原文

    Hi everyone and happy new year btw :), i trying to program internal module RTCC of this PIC, but i don't get that SECONDS registers increment! It's like doens't work, why?¿ this is my code:


typedef struct t {
int sec;
int min;
int hour;
int mday;
int mon;
int year;
int wday;
int yday;
int isdst;
} temps_RTCC;

temps_RTCC tempsConfig;
temps_RTCC visorTemps;

void main(void)
{

RTCWREN(= 1;
    RTCCONbits.RTCEN = 0;
    RTCCONbits.RTCCLKSEL = 0; //SOSC
    RTCCONbits.HALFSEC = 0;


       YEAR = 0x17; // year
        MONTH = 0x11; // month
        WEEKDAY = 0x05; // weekday
        DAY = 0x17; // day
        HOURS = 0x08; // hours
        MINUTES = 0x19; // minutes
        SECONDS = 0x44; // seconds
   
    ALRMCONbits.ALRMEN = 0;
    ALRMRPT = 0x00; // repetiotions
    ALRMMTH = 0x11; // month
    ALRMWD = 0x05; // weekday
    ALRMDAY = 0x17; // day
    ALRMHR = 0x08; // hours
    ALRMMIN = 0x19; // minutes
    ALRMSEC = 0x44; // seconds

    ALRMCONbits.ALRMEN = 1; // Re-enable the alARM

    ALRMCON = 0xA4;
    RTCCAL = 0x00; // calibration register

    RTCCONbits.RTCEN = 1;
    RTCWREN = 0;

    PIR8bits.RTCCIF = 0; // Clear the RTCC interrupt flag
    PIE8bits.RTCCIE = 1; //Enable RTCC interrupt

tempsConfig.hour = 0x00;
    tempsConfig.min = 0x00;
    tempsConfig.sec = 0x01;
    tempsConfig.mon = 0x01;
    tempsConfig.year = 0x18;
    tempsConfig.mday = 0x03;
    tempsConfig.isdst = 0x02;
    tempsConfig.yday = 0x02;

    RTCC_TimeSet(&tempsConfig); //Configuracio del temps

while (1)
    {
        CLRWDT(); //No watchadog
        
        RTCC_TimeGet(&visorTemps);

        sendIntegerToLcd(0,2, visorTemps.sec);

     }
}



This code is from MCC, and i should display the increment seconds, but it doens't work


Thanks

回帖(18)

李雨晨

2018-11-22 15:18:56
从你的描述“但我没有得到秒寄存器增量!”我的结论是什么都不增加,不仅仅是秒?你有一个32千赫晶体安装,你有SOSC启用?你可以看到你的FRM的第26.4章。你也可以用SOSC作为输入来测试定时器0,看看你的问题是否与RTC或时钟源有关。

以上来自于百度翻译


      以下为原文

    From your description "but i don't get that SECONDS registers increment!" I conclude that NOTHING increments, not only the seconds ?
 
Do you have a 32 kHz crystal mounted and do you have SOSC enabled ?
See chapter 26.4 of your FRM.
You could also test Timer 0 with SOSC as input to see whether your problem is related to the RTC or the clock source.
举报

李秀容

2018-11-22 15:24:33
谢谢你的回答,是的,我已经安装了水晶32千赫,SSOC也启用了,我试着在Time1中断,从SOSC时钟,LED和LED看起来像快速闪烁,但我可以看到它完全闪烁。秒寄存器不递增,任何寄存器工作。

以上来自于百度翻译


      以下为原文

    Thanks for answer, yes, i have mounted crystal 32 khz, and SOSC's enabled too, i've tried to toogle led on timer1 interrupt, clocked from SOSC, and LED look like fast blink, but i can see it perfectly blink.
SECONDS register doesn't increment, and any register work.
举报

李涛

2018-11-22 15:37:23
你必须解锁时钟硬件。编写时间数据,并启动。我有一些代码在16位,你可以看到时钟硬件解锁。

以上来自于百度翻译


      以下为原文

    You have to unlock the clock hardware.
Write the time data and enable to start.
 
I have some code in 16bit where you can see the clock hardware unlocked.
.include "xc.inc"
.include "UtilityLib2.inc"
.global _setinternalclock
.section utilitycode,code
;----------------------------------------------------
.equ DT,    w0    ;DateTime_t *

_setinternalclock:  ;void setinternalclock(DateTime_t *DT);  bcd
    mov     #0x55,w0
    mov     w0,NVMKEY
    mov     #0xAA,w0
    mov     w0,NVMKEY
    bset    RCFGCAL,#RTCWREN        ;Set RTCWREN bit
    bclr    RCFGCAL,#RTCEN
    mov     RCFGCAL,w0
    ior     #0x300,w0            ;all
    mov     w0,RCFGCAL
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;set date
    mov     [DT+DT_Year],w0        ;get year
    mov     w0,RTCVAL            ;set year
    mov     [DT+DT_DateMonth],w0    ;get date/month
    mov     w0,RTCVAL            ;set month/date
    ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ;set time
    mov     [DT+DT_HourDay],w0        ;get hour/day
    mov     w0,RTCVAL            ;set hour/day
    mov     [DT+DT_SecondMinute],w0    ;get sec/min
    mov     w0,RTCVAL            ;set min/sec
    bset    RCFGCAL,#RTCEN
    bclr    RCFGCAL,#RTCWREN        ;Set RTCWREN bit
    return
;----------------------------------------------------
.end
Using this structure
typedef struct{
    union{
        struct{
            unsigned char   Second;
            unsigned char   Minute;
        };
        unsigned int    SecondMinute;
    };
    union{
        struct{
            unsigned char   Hour;
            unsigned char   Day;
        };
        unsigned int    HourDay;
    };
    union{
        struct{
            union{
                struct{
                    unsigned char   Date;
                    unsigned char   Month;
                };
                unsigned int    DateMonth;
            };
            unsigned int    Year;
        };
        unsigned long   TotalSeconds;
    };
}DateTime_t;
举报

李秀容

2018-11-22 15:49:40
但是对于PIC16F不是真的…如果我添加:NVMCON2= 0x55;NVMCON2= 0xAA;它仍然不工作。

以上来自于百度翻译


      以下为原文

    but is not true for PIC16F... if i add:
 
NVMCON2 = 0x55;
NVMCON2 = 0xAA;
 
it doesn't work still.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分