AN205179 F²MC-8FX Family MB95410H/470H Series 8-Bit Microcontroller One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation.pdf

AN205179
F²MC-8FX Family MB95410H/470H Series 8-Bit Microcontroller One Phase Power
Meter (CS5464) Solution Real Time Clock and Data Storage Operation
Associated Part Family: MB95410H/470H Series
This application note describes how to use One Phase Power Meter (CS5464) solution’s real time clock and data
storage function.
1
Introduction
This application note describes how to use One Phase Power Meter (CS5464) solution’s real time clock and data
storage function.
Section 2 explains the Background.
Section 3 explains the HW Diagram.
Section 4 explains the HW Reference SCH.
Section 5 explains the FW diagram.
Section 6 explains the FW Function List.
2
Background
Background of Real time Clock and Data Storage Function
2.1
Overview
In the power meter solution, real time clock unit is RX8025T, and data storage unit is AT24C64. The communication
2
method between MCU and these two units is I C communication.
3
HW Diagram
Hardware diagram of real time clock unit and data storage unit
3.1
HW Diagram of Real Time Clock Unit and Data Storage Unit
Figure 1. Hardware diagram
RX8025T
MB95F418
MB85RC64
www.cypress.com
Document No. 002-05179 Rev. *A
1
One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation
4
HW Reference SCH
Hardware reference SCH of real time clock unit and data storage unit
Figure 2. Real time Clock Unit
VCC
I2C_SCL
VCC
C30
C31
106
104
1
2
3
4
5
6
7
R56 2K
U13
14
13
12
11
10
9
8
T1(CE) NC4
SCL
SDA
FOUT T2(VPP)
NC1
GND
TEST
/INT
VDD
NC3
FOE
NC2
R54
I2C_SDA
10K
GND
RTC_nINTA
RX8025T
Figure 3. Data Storage Unit
A0 VCC
A1
WP
A2 SCL
GND SDA
8
7
6
5
MB85RC64
www.cypress.com
C28
R49
R47
104
10K
10K
2
R65
R55
10K
10K
3
I2C_SCL
Q13
BSS138/SOT23
1
1
2
3
4
U12
VCC
1
3.3V
2
3
Q12
BSS138/SOT23
Document No. 002-05179 Rev.*A
I2C_SDA
2
One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation
5
FW diagram
Firmware system diagram
5.1
Real time Clock Unit Communication Protocol
For RTC function’s communication protocol, refer to the IIC bus protocol which is shown in Figure 4.
Description is as below:
1.
Master sends a start condition and a byte data including 7 bits slave address and 1 bit R/W.RTC’s salve address
is 0110010.
2.
Master waits ACK from slave.
3.
Master sends a byte RTC register address (0~F), which is shown in Figure 5.
4.
Master waits ACK from slave.
5.
Master sends n bytes data to slave. And at the end of each byte master needs to wait slave’s ACK.
6.
Master sends a stop condition to slave.
Figure 4. RTC Communication Protocol
www.cypress.com
Document No. 002-05179 Rev.*A
3
One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation
Figure 5. RTC’s register Description
www.cypress.com
Document No. 002-05179 Rev.*A
4
One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation
5.2
Data Storage Unit Communication Protocol
For EEPROM function’s communication protocol, refer to the IIC bus protocol which is shown in Figure 4.
Description is as below:
5.3
1.
Master sends a start condition and a byte data including 7 bits slave address and 1 bit R/W.EEPROM’s salve
address is 1010000.
2.
Master waits ACK from slave.
3.
Master sends 2 bytes EEPROM data address (0x0000~0xFFFF).First sends the address high byte. Then sends
the address low byte. And in the end of each byte master needs to wait slave’s ACK.
4.
Master sends n bytes data to slave. And in the end of each byte master need to wait slave’s ACK.
5.
Master sends a stop condition to salve.
Firmware System Diagram
Figure 6: Firmware System Diagram
Start
Init IIC module
Init RX8025T registers
Enable 1s interrupt
1s interrupt?
N
Y
Update the clock
www.cypress.com
Document No. 002-05179 Rev.*A
5
One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation
6
FW Function List
6.1
API
Table 1. FW API List
Function Prototype
6.2
Description
void RTC_Config(void)
Config working mode for RTC RX8025T
void RTC_IntDisable(void)
Disable interrupt output for RTC
void RTC_Read(void)
Read RTC RX8025T calendar data
void RTC_Write(void)
Set RTC RX8025T calendar data
void EEPROM_Write(INT8U *eeBuff)
Write a series of data byte to EEPROM
void EEPROM_Read(INT8U *eeBuff)
Read a series of data byte from EEPROM
INT8U EEPROM_Write_Verify(INT8U *eeBuff)
Write a series of data byte to EEPROM and verify the result
INT8U EEPROM_Read_Verify(INT8U *eeBuff)
Read a series of data byte from EEPROM and validate
checksum
HAL
Table 2. FW HAL List
Function Prototype
Description
void IIC_Init(void)
Init IIC bus
INT8U IIC_Acknowledge(void)
waitting ACK from slave
INT8U IIC_Start(INT8U slave_address)
Master generates a START condition on IIC bus and
transmit slave_address
INT8U IIC_Restart(INT8U slave_address)
Master generates a RESTART condition on IIC bus
INT8U IIC_Stop(void)
Master generates a STOP condition on IIC bus
INT8U IIC_SendByte(INT8U outDat)
Master send out a byte of data and return with ACK/NACK
INT8U IIC_Write(INT8U *buff, INT8U total)
Master write a string of bytes through IIC us
INT8U IIC_ReadByte(void)
Master read a byte of data and set ACK/NACK
INT8U IIC_Read(INT8U *buff, INT16U total)
Master read a string of data bytes through IIC us
www.cypress.com
Document No. 002-05179 Rev.*A
6
One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation
7
Additional Information
For more information on Cypress products, please visit the following website:
http://www.cypress.com/cypress-microcontrollers
www.cypress.com
Document No. 002-05179 Rev.*A
7
One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation
Document History
Document Title: AN205179 – F²MC-8FX Family MB95410H/470H Series 8-Bit Microcontroller One Phase Power Meter
(CS5464) Solution Real Time Clock and Data Storage Operation
Document Number: 002-05179
Revision
ECN
Orig. of
Change
Submission
Date
**
-
HUAL
06/18/2011
Initial release
*A
5277409
HUAL
05/20/2016
Migrated Spansion Application Note MCU-AN-500119-E-10 to Cypress format.
www.cypress.com
Description of Change
Document No. 002-05179 Rev.*A
8
One Phase Power Meter (CS5464) Solution Real Time Clock and Data Storage Operation
Worldwide Sales and Design Support
Cypress maintains a worldwide network of offices, solution centers, manufacturer’s representatives, and distributors. To find
the office closest to you, visit us at Cypress Locations.
PSoC® Solutions
Products
ARM® Cortex® Microcontrollers
cypress.com/arm
PSoC 1 | PSoC 3 | PSoC 4 | PSoC 5LP
Automotive
cypress.com/automotive
Cypress Developer Community
Clocks & Buffers
cypress.com/clocks
Interface
cypress.com/interface
Lighting & Power Control
cypress.com/powerpsoc
Memory
cypress.com/memory
PSoC
cypress.com/psoc
Touch Sensing
cypress.com/touch
USB Controllers
cypress.com/usb
Wireless/RF
cypress.com/wireless
Forums | Projects | Videos | Blogs | Training | Components
Technical Support
cypress.com/support
PSoC is a registered trademark and PSoC Creator is a trademark of Cypress Semiconductor Corporation. All other trademarks or registered trademarks
referenced herein are the property of their respective owners.
Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
Phone
Fax
Website
: 408-943-2600
: 408-943-4730
: www.cypress.com
© Cypress Semiconductor Corporation, 2011-2016. This document is the property of Cypress Semiconductor Corporation and its subsidiaries, including
Spansion LLC (“Cypress”). This document, including any software or firmware included or referenced in this document (“Software”), is owned by
Cypress under the intellectual property laws and treaties of the United States and other countries worldwide. Cypress reserves all rights under such
laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights, trademarks, or other
intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with
Cypress governing the use of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to
sublicense) (1) under its copyright rights in the Software (a) for Software provided in source code form, to modify and reproduce the Software solely for
use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in binary code form externally to end
users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of
Cypress’s patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for
use with Cypress hardware products. Any other use, reproduction, modification, translation, or compilation of the Software is prohibited.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD
TO THIS DOCUMENT OR ANY SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. To the extent permitted by applicable law, Cypress reserves the right to
make changes to this document without further notice. Cypress does not assume any liability arising out of the application or use of any product or
circuit described in this document. Any information provided in this document, including any sample design information or programming code, is
provided only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and
safety of any application made of this information and any resulting product. Cypress products are not designed, intended, or authorized for use as
critical components in systems designed or intended for the operation of weapons, weapons systems, nuclear installations, life-support devices or
systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous substances
management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A
critical component is any component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or
system, or to affect its safety or effectiveness. Cypress is not liable, in whole or in part, and you shall and hereby do release Cypress from any claim,
damage, or other liability arising from or related to all Unintended Uses of Cypress products. You shall indemnify and hold Cypress harmless from and
against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of
Cypress products.
Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or
registered trademarks of Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other
names and brands may be claimed as property of their respective owners.
www.cypress.com
Document No. 002-05179 Rev.*A
9