΢²¨EDAÍø£¬¼ûÖ¤Ñз¢¹¤³ÌʦµÄ³É³¤£¡
Ê×Ò³ > Ó²¼þÉè¼Æ > ǶÈëʽÉè¼Æ > MSP430ϵͳʵʱʱÖÓRTCѧϰÈÕÖ¾

MSP430ϵͳʵʱʱÖÓRTCѧϰÈÕÖ¾

ʱ¼ä£º11-25 À´Ô´£º»¥ÁªÍø µã»÷£º
¶ÁȡʵʱʱÖÓ£º

1¡¢ RTCRDY Ϊ0ʱ£¬²»ÄÜÈ¡¶ÁȡʵʱʱÖÓ

RT0PSÔ´ÓÚACLK£¬ÎªÁËʵʱʱÖÓÈÕÀúµÄÕýÈ·µÄÔËÐУ¬ACLK±ØÐëÊÇ32768Hz¡£(Ò׳ö´í£©

¶¨Ê±£º

Ò»¡¢Ã¿Ð¡Ê±ÄÖÒ»´Î£ºÃ¿Ò»Ð¡Ê±µÄ15·ÖÖÓÄÖÒ»´Î£º

1¡¢½«RTCAMINÉèÖóÉ15£»2¡¢ÉèÖÃRTCAMINµÄAEλºÍÇå³ýÄÖÖӼĴæÆ÷µÄÆäËüËùÓÐAEλ

3¡¢AF»áÔÚ£º00£º14£º59µ½00£º15£º00¡¢01£º14£º59µ½01£º15£º00¡¢02£º14£º59µ½02£º15£º00µÈµÈʱ¿Ì±»ÖÃλ¡£

¶þ¡¢ÔÚÿÌì04£º00£º00ʱ¿ÌÄÖ£º

1¡¢RTCAHOURλÖÃλ³É4£»2¡¢ÉèÖÃRTCHOURµÄAEλºÍ¸´Î»ÄÖÖӼĴæÆ÷µÄËùÓÐÆäËüAEλ

3¡¢AF¾Í»áÔÚ03£º59£º59µ½04£º00£º00ʱ¿Ì±»ÖÃλ¡£

Èý¡¢ÔÚÿÌì06£º30£º00ʱ¿ÌÄÖ£º

1¡¢ ½«RTCAHOURÉèÖóÉ6£¬½«RTCAMIN ÉèÖóÉ30¡£

2¡¢ÉèÖÃRTCAHOURºÍRTCAMINµÄAE룬¼´¿ÉʹÄÜÄÖÖÓ

3¡¢ AF뽫»áÔÚÿһ¸ö06£º29£º59µ½06£º30£º00µÄ¹ý¶Éʱ¿Ì±»ÖÃλ

ËÄ¡¢ÔÚÿÖܶþ 06£º30£º00ʱ¿ÌÄÖ£º

1¡¢ RTCADOWλÉèÖóÉ2£¬RTCAHOURÉèÖóÉ6£¬RTCAMIN½«Òª±»ÉèÖóÉ30¡£

2¡¢ ÉèÖÃRTCADOW¡¢RTCAHOURºÍRTCAMINµÄAE룬ÄÖÖÓ¼´±»Ê¹ÄÜ¡£

3¡¢ AF뽫»áÔÚRTCDOWλ´Ó1 µ½2µÄ¹ý¶ÉºóºÍ06£º29£º59µ½06£º30£º00µÄ¹ý¶Éʱ¿Ì±»ÖÃλ¡£

Îå¡¢ÔÚÿÔµÚÎåÌìµÄ06£º30£º00ʱ¿ÌÄÖ£º

1¡¢ RTCADAY뽫ҪÉèÖóÉ5£¬RTCAHOUR뽫Ҫ±»ÉèÖóÉ6£¬RTCAMIN뽫Ҫ±»ÉèÖóÉ30¡£

2¡¢ ÉèÖÃRTCADAYλ¡¢RTCAHOURλºÍRTCAMINλµÄAE룬ÄÖÖÓ¼´±»Ê¹ÄÜ¡£

3¡¢ AF뽫ҪÔÚ06£º29£º59µ½06£º30£º00µÄ¹ý¶Éʱ¿ÌºÍRTCADAYµÈÓÚ5µÄʱ¿Ì±»ÖÃλ¡£

ʵʱʱÖÓģʽϵļä¸ôʱ¼äÖжϣº

RTCCTL01 = RTCBCD+RTCMODE+RTCTEVIE+RTCAIE;

RTCMODE£º 0:Counter 1: Calendar

ÖÃλRTCAIE λ¾ÍʹÄÜÁËʱÖÓÖжϹ¦ÄÜ

ÖÃλRTCTEVIE λ¾ÍʹÄÜʱ¼ä¼ä¸ôÖжϹ¦ÄÜ£¬ÖÃλRTCTEVIFG

RTCTEV£º00 ·ÖÖÓÌø±ä

01 СʱÌø±ä

10 ÿÌìÁ賿£¨00:00£©

11 ÿÌìÕýÎç(12:00)

ÒÔÉϾùÔÚRTCMODE=1ģʽÏ¡£

//ÌìÖжϡ£ÖÃλRTCRDYIE λ»áʹÄÜÖжϣ¬RTCRDY λ´¥·¢ÊµÊ±Ê±ÖÓÖжÏRTCRDYIFG

¼ÆÊýÆ÷ģʽÖеÄʵʱʱÖÓÖжÏ

ʱ¼ä¼ä¸ôÖжϣº

ʵʱʱÖÓÖжϣ¨RTCTEVIFG£©

ÅäÖóÉ8λ¡¢16λ¡¢24λ»òÕß32λÖеÄÒ»ÖÖÒç³öʱÒý·¢Ò»¸ö´¥·¢Ê¼þ¡£´¥·¢Ê¼þ¿ÉÓÉRTCTEVλ½øÐÐÑ¡Ôñ

ÖÃλRTCTEVIEλʹÄÜÖжÏ

ÔÚ¼ÆÊýÆ÷ģʽÖУ¬Èý¸öÖжÏÔ´ÊÇ¿ÉÓõģ¬Æä·Ö±ðÊÇRT0PSIFG¡¢RT1PSIFGºÍRTCTEVIFG¡£RTCAIFGλºÍRTCRDYIFGλ±»Çå³ý¡£RTCRDYIEºÍRTCAIEλ¿ÉÒÔºöÂÔ¡£

1ͨ¹ýÉèÖÃRT0IP룬¿ÉÒÔÑ¡ÔñʹRT0PSIFGλÓÃÀ´Éú³É¼äЪÖжϡ£

2ÔÚ¼ÆÊýÆ÷ģʽ£¬RT0PSλʱÖÓÔ´£¬Ô´×ÔÓÚACLK»òÕßSMCLK£¬Ò²¿ÉÒÔÊÇ»ùÓÚACLK»òÕßSMCLKʱÖÓÔ´µÄ2·ÖƵ¡¢4·ÖƵ¡¢8·ÖƵ¡¢16·ÖƵ¡¢32·ÖƵ¡¢64·ÖƵ¡¢128·ÖƵºÍ256·ÖƵ×÷ΪʱÖÓÔ´¡£

3ÉèÖÃRT0PSIEλ¿ÉÒÔʹÄÜÖжϡ£

1ͨ¹ýÉèÖÃRT1IP룬¿ÉÒÔÑ¡ÔñµØÈÃRT1PSIFGλÓÃÀ´Éú³É¼äЪÖжϡ£

2ÔÚ¼ÆÊýÆ÷ģʽÏ£¬RT1PSλʱÖÓÔ´£¬Ô´ÓÚACLK¡¢SMCLK»òÕßÊÇRT0PSλµÄÊä³ö£¬Ò²¿ÉÒÔÊÇÒÔÉÏʱÖÓÔ´µÄ2·ÖƵ¡¢4·ÖƵ¡¢8·ÖƵ¡¢16·ÖƵ¡¢32 ·ÖƵ¡¢64·ÖƵ¡¢128·ÖƵºÍ256·ÖƵºó²úÉúеÄʱÖÓÔ´×÷ΪʱÖÓ¡£

3ÉèÖÃRT1PSIEλ¿ÉÒÔʹÄÜÖжϡ£

Ò»¸ö¼òµ¥¶ø°²È«¶ÁȡʵʱʱÖӼĴæÆ÷µÄ·½·¨ÊÇÀûÓÃRTCRDYIFGÖжϱê־λ¡£ÖÃλRTCRDYIEλʹÄÜ

RTCRDYIFGÖжϡ£Ò»µ©ÖжÏʹÄÜ£¬ÔÚRTCRDYλÉÏÉýÑصÄʱºò½«»á²úÉúÖжϣ¬ÖÂʹRTCRDYIFG±»ÖÃλ¡£ÔÚÕâ

Ò»µãÉÏ£¬ÕâÒ»Ó¦Óü¸ºõÓÐÍêÕûµÄÒ»ÃëÖÓ°²È«µØÈ¥¶ÁÈ¡ÈÎÒ»¸öʵʱʱÖӼĴæÆ÷¡£Õâһͬ²½µÄ´¦Àí·½Ê½·ÀÖ¹ÔÚʱ¼ä

Ìø±äµÄ¹ý³ÌÖжÁȡʱ¼äÖµ¡£µ±Öжϵõ½ÏìÓ¦µÄʱºò£¬RTCRDYIFG»á×Ô¶¯¸´Î»£¬Ò²¿ÉÒÔÈí¼þ¸´Î»¡£

ÔÚ¼ÆÊýÆ÷ģʽÏ£¬RTCRDYλ±£³Ö¸´Î»¡£¿ÉÒÔ²»¹ØÐÄRTCRDYIE룬²¢ÇÒRTCRDYIFGά³Ö¸´Î»¡£

×ÊÁÏ£º

http://www.jdzj.com/pic/Class347/Class410/20080804043437.html

ÉèÖÃRTCʱ¼ä£º

void main(void)

{

WDTCTL = WDTPW + WDTHOLD; // Stop Watchdog Timer

RTCCTL01 = RTCBCD+RTCHOLD+RTCMODE+RTCTEVIE+RTCAIE;

// RTC enable, BCD mode,

// alarm every Minute,

// enable RTC interrupt

// Init time

RTCSEC = 0x00; // Set Seconds

RTCMIN = 0x32; // Set Minutes

RTCHOUR = 0x10; // Set Hours

// Init date

RTCDOW = 0x03; // Set DOW

RTCDAY = 0x30; // Set Day

RTCMON = 0x04; // Set Month

RTCYEAR = 0x2008; // Set Year

RTCCTL01 &= ~RTCHOLD; // Enable RTC

P1DIR |= 0x01; // Set P1.0 to output direction

__bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/ interrupt

}

¶ÁÈ¡RTCʱ¼ä£º

//

//

Copyright © 2017-2020 ΢²¨EDAÍø °æȨËùÓÐ

ÍøÕ¾µØͼ

Top