Using the DS87C530/DS5250 Real

[09-13 17:03:26]   来源:http://www.88dzw.com  控制技术   阅读:8357

文章摘要:Reading The TimeReading the current time from the RTC is accomplished by the following procedure:Disable all interrupts by clearing the EA bit (IE.7) Set the RTCRE bit (RTCC.3) Wait 4 machine cycles Read the appropriate register(s) within 1ms of RTCRE being set Clear the RTCRE bit (RTCC.3) Enable in

Using the DS87C530/DS5250 Real,标签:计算机控制技术,工厂电气控制技术,http://www.88dzw.com

Reading The Time

Reading the current time from the RTC is accomplished by the following procedure:
  1. Disable all interrupts by clearing the EA bit (IE.7)
  2. Set the RTCRE bit (RTCC.3)
  3. Wait 4 machine cycles
  4. Read the appropriate register(s) within 1ms of RTCRE being set
  5. Clear the RTCRE bit (RTCC.3)
  6. Enable interrupts by setting the EA bit (IE.7)

Setting The Time

The time is set by writing to the Clock Registers. The Second, Minute, Hour, Day of the Week, and Day Count can be set by writing to the respective registers. It is not possible to set the Real-time Clock Subsecond Register (RTCS; FBh). This register is automatically reset to 00h when the RTCWE bit is cleared, either through software or the automatic time-out of the 1ms write window. The procedure for setting an RTC time register is as follows:
  1. Disable all interrupts by clearing the EA bit (IE.7)
  2. Perform a Timed Access procedure
  3. Set the RTCWE bit (RTCC.2)
  4. Wait 4 machine cycles
  5. Write the appropriate register(s) within 1ms of RTCWE being set
  6. Perform a Timed Access procedure
  7. Clear the RTCWE bit (RTCC.2)
  8. Enable interrupts by setting the EA bit (IE.7)

Using The RTC Alarm

The RTC alarm function is used to generate an interrupt when the RTC value matches selected alarm register values. An alarm can be triggered by a match on one or more of the following alarm registers: Subsecond (RTASS;F2h), Second (RTAS; F3h), Minute (RTAM; F4h), and Hour (RTAM; F5h). Note that there is no alarm register associated with the RTC Day or Day of Week Registers. If an alarm is desired on a specific date, an alarm can be executed once a day and user software can compare the current date against the Day Register. It is not necessary to set the RTC Write Enable bit when setting the alarm registers.

The alarm can be set to occur on a match with any or all of the alarm registers. An alarm can occur on a unique time of day, or a recurring alarm can be programmed every subsecond, second, minute, or hour. The specific alarm registers to be compared are selected by setting or clearing the corresponding compare enable bits (RTCC.7-4). Any compare bit which is cleared will result in that register being treated as a 'Don't Care' when evaluating alarm conditions. Clearing all the compare enable bits will disable the ability of the RTC to cause an interrupt, and will immediately clear the RTC Interrupt Flag (RTCC.1). Unlike some interrupts, the RTC flag is not cleared by exiting the RTC interrupt service routine and must be done in software.

The general procedure for setting the RTC alarm registers to cause a RTC interrupt is as follows:
  1. Clear the RTC Interrupt Enable bit (EIE.5)
  2. Clear all RTC Alarm Compare enable bits (ANL RTCC, #0Fh)
  3. Write one or more RTC Alarm registers
  4. Set the desired RTC Alarm Compare enable bits
  5. Set the RTC Interrupt Enable bit (EIE.5)
  6. Setting the alarm to cause an interrupt for a single time during a 24-hour period is done by setting all the alarm registers to the desired value and enabling all compare bits. For example, if an alarm was desired at 11:45:00 am, the following configuration would be used:

    Alarm Subsecond (RTASS) 00 subseconds = 00h
    Alarm Second (RTAS) 00 seconds = 00h
    Alarm Minute (RTAM) 45 minutes =2Dh
    Alarm Hour (RTAH) 11 hours =0Bh
    Clock Control (RTCC) subsecond compare = F1h
      second compare  
      minute compare  
      hour compare  

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  下一页


Tag:控制技术计算机控制技术,工厂电气控制技术控制技术

《Using the DS87C530/DS5250 Real》相关文章