AVR1631 - Energy Meter Reference Design with ATxmega32A4  Rev 1.0
 All Data Structures Files Functions Variables Typedefs Macros
meter_rtc.c File Reference

Metering Algorithm implementation. More...

#include "meter.h"

Go to the source code of this file.

Functions

void rtc_init ()
 ISR (RTC_OVF_vect)
void update_time ()

Variables

uint8_t power_status_flag = 0
 hold the status of mains power supply
const uint8_t days_lookup [12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
 lookup table for number of days in a month
RTC_BCD_t rtcTime = {0,0,0,1,1,2012}
 structure for holding the time value

Detailed Description

Metering Algorithm implementation.

Application note:
AVR1631: Energy Meter Reference Design with ATxmega32A4
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author
Atmel Corporation: http://www.atmel.com
Support email: avr@a.nosp@m.tmel.nosp@m..com

$Revision: 1.0
$Date: 2012-07-01 10:10:10 +0530

Copyright (c) 2008, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  1. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  1. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file meter_rtc.c.

Function Documentation

ISR ( RTC_OVF_vect  )

breif The RTC ISR occurs in every sec. The time and date is updated in this function and the rtc_flag is set

update the time and date

check the status of mains power supply

if power is on, set the rtc_flag

if power is off, clear the rtc_flag

Definition at line 77 of file meter_rtc.c.

void rtc_init ( )

brief This function initilize RTC to external clock and 1 sec interrupt.

Definition at line 63 of file meter_rtc.c.

void update_time ( )

breif This function updates the date and time

Definition at line 106 of file meter_rtc.c.