Maxim实时时钟芯片设计指南5413-二进制编码十进制(BCD)格式实时时钟中的状态机逻辑
网上DS12C887的文章涉及到时间的存储格式使用的都是二进制代码,究竟使用BCD码该如何操作?正好美信官网上有一篇文章。美信官网不稳定,先贴到这里,有时间再翻译。
State Machine Logic in Binary-Coded Decimal (BCD)-Formatted Real-Time Clocks
A similar version of this article appears on Electronic Design, July 2012.
Introduction

| Register | Minimum (hex) | Maximum (hex) | Carry to Register |
| Hundredths | 00 | 99 | Seconds |
| Seconds | 00 | 59 | Minutes |
| Minutes | 00 | 59 | Hours |
| Hours (12-hour mode) | 41 | 72 | AM PM, PM AM + Day & Date |
| Hours (24-hour mode) | 00 | 23 | Day & Date |
| Day | 01 | 07 | — |
| Date | 01 | 31* | Month (*Month and Year dependent) |
| Month | 01 | 12 | Year |
| Year | 00 | 99 | Century (register or bit) |
| Century | 00 | 99 | — |
Register Descriptions
7). The Day register only has three functioning bits, so even though it initially seems impossible for the user to load a value greater than 7, any hex value > 7 written would store the bad value logic-ORd with the three functioning bits (07h) (e.g., writing 1Fh would store a 07h, or writing F5h would store a 05h). Normal calendar convention is to define Sunday= 1, but that definition is arbitrary and fully under the user's control.| Table 2. Last Date of Month | ||
| Calendar Month | Numeric Month | End Date |
| January, March, May, July, August, October, December | 1, 3, 5, 7, 8, 10, 12 | 31 |
| April, June, September, November | 4, 6, 9, 11 | 30 |
| February | 2 | 28 (typical year), 29 (leap year) |
Leap_Year = ; default to No
If MODULO (CALENDAR_YEAR/) == ; divisible by ?
If MODULO (CALENDAR_YEAR/) == ; divisible by ?
If MODULO (CALENDAR_YEAR/) == ; divisible by ?
Leap_Year =
end ; if
else
Leap_Year =
end ; if
end ; if
Results When Illegal Data Is Written
| BCD | Binary | |
| 2Ah | 00101010 | Write to Month |
| 9Fh | 10011111 | Enabled bits in Month register (with Century bit) |
| 0Ah | 00001010 | Resulting content of "0Ah" after writing the Month |
| 12h | 00010010 | Logic match for "maximum value" |
| BCD | Binary | |
| FFh | 11111111 | Write to Hours |
| 7Fh | 01111111 | Enabled bits in Hours register |
| 7Fh | 01111111 | Resulting content of "7Fh" when reading the Hours |
| BCD | Binary | |
| 38h | 00111000 | Write to Hours |
| 7Fh | 01111111 | Enabled bits in Hours register |
| 38h | 00111000 | Resulting content of "38h" when reading the Hours |
| BCD | Binary | |
| AAh | 10101010 | Write to Seconds |
| FFh | 11111111 | Enabled bits in Seconds register |
| AAh | 10101010 | Resulting content of "AAh" when reading the Seconds |
| BCD | Binary | |
| 2Dh | 00101101 | Write to Date |
| 3Fh | 00111111 | Enabled bits in Hours register |
| 2Dh | 00101101 | Resulting content of "2Dh" when reading the Hours |
Summary
Maxim实时时钟芯片设计指南5413-二进制编码十进制(BCD)格式实时时钟中的状态机逻辑的更多相关文章
- Maxim实时时钟芯片设计指南5791-关于编写健壮的实时时钟控制代码的提示
用DS12C887设计一个万年历,虽然反复查看说明书,还是出各种的错误. 因此,从美信官网查询资料,翻译的不太通,凑合着对照看. 原文链接 Tips for Writing Bulletproof R ...
- Lsyncd实时同步搭建指南
linux文件实时同步: inotify+rsync.sersync.lsyncd工具比较 一.inotify + rsync 最近一直在寻求生产服务服务器上的同步替代方案,原先使用的是inotify ...
- 【代码】二进制转BCD [转]
BCD:Binary Coded Decimal 即用4位二进制编码表示1位的十进制数. 定义:BCD码这种编码形式利用了四个位元来储存一个十进制的数码,使二进制和十进制之间的转换得以快捷的进行. ...
- 使用Socket通信实现Silverlight客户端实时数据的获取(模拟GPS数据,地图实时位置)
原文:使用Socket通信实现Silverlight客户端实时数据的获取(模拟GPS数据,地图实时位置) 在上一篇中说到了Silverlight下的Socket通信,在最后的时候说到本篇将会结合地图. ...
- .net下二进制序列化的格式分析[转]
.net下二进制序列化的格式分析[转] -- 综合应用 (http://www.Host01.Com/article/Net/00020003/) --- .net下二进制序列化的格式分析 (http ...
- FPGA中将十进制数在数码管中显示(verilog版)--二进制转换为BCD码
这周有朋友问怎样在fpga中用数码管来显示一个十进制数,比如1000.每个数码管上显示一位十进制数.如果用高级语言来分离各位,只需要分别对该数做1000,100,10对应的取商和取余即可分离出千百十个 ...
- FPGA加三移位算法:硬件逻辑实现二进制转BCD码
本文设计方式采用明德扬至简设计法.利用FPGA来完成显示功能不是个很理想的方式,当显示任务比较复杂,要通过各种算法显示波形或者特定图形时,当然要用单片机通过C语言完成这类流程控制复杂,又对时序要求不高 ...
- C语言之linux内核--BCD码转二进制与二进制转BCD码(笔试经典)
在分析代码之前,我们先来了解一下,BCD码和二进制到底区别在哪? 学习过计算机原理的和数字电子技术这两门课的都会知道这两个到底是什么含义,也有的同学学过了,考过了,过了一段时间又忘记了,今天,我们通过 ...
- 基于Verilog HDL的二进制转BCD码实现
在项目设计中,经常需要显示一些数值,比如温湿度,时间等等.在数字电路中数据都是用二进制的形式存储,要想显示就需要进行转换,对于一个两位的数值,对10取除可以得到其十位的数值,对10取余可以得到个位的数 ...
随机推荐
- 打印图片的属性和实现另存图片功能以及使用numpy
上一篇我们已经学了如何读取图片的功能了以及和opencv的环境搭建了,今天接着来学习,哈哈哈,今天刚好五一,也没闲着,继续学习. 1. 首先我们来实现打印出图片的一些属性功能, 先来看一段代码: im ...
- App的数据如何用python抓取
前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. App中的数据可以用网络爬虫抓取么 答案是完全肯定的:凡是可以看到的APP数 ...
- paddlehub Test on win10
conda 构建虚拟环境 1)虚拟环境下安装paddlepaddle 1.7 2)pip install paddlehub 3)添加环境变量hub_home,以免模型把c盘撑爆 4)下载的模型在.p ...
- R - Cow and Message CodeForces - 1307C
思路对了,但是不会写. 等差数列长度不是1就是2,所以不是一个字母就是俩字母,一开始写的时候直接枚举两个字母,然后让次数相乘.这样是不对的,比如abaabb,字母ab的个数应该是3+2+2,因该是每一 ...
- Oracle使用fy_recover_data恢复truncate删除的数据
(一)truncate操作概述 在生产中,truncate是使用的多的命令,在使用不当的情况下,往往会造成表的数据全部丢失,恢复较为困难.对于truncate恢复,常见的有以下几种方法可以进行恢复: ...
- 牛客网 - vivo2020届春季
牛客网 - vivo2020届春季 1.[编程题]手机屏幕解锁模式 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M 现有一个 3x3 规格的 Android ...
- kubernetes的Service是什么?
service到底是什么? k8s的service定义了一个服务的访问入口地址,前端的应用通过这个入口地址访问其背后的一组由pod副本组成的集群实例.来自外部的访问请求被负载均衡到后端的各个容器应用上 ...
- java Int类型转为double 类型;string转double
int a=12; double b=(double)a; or double c=Double.valueOf((double)a); string a_s="12"; doub ...
- TensorFlow keras卷积神经网络 添加L2正则化
model = keras.models.Sequential([ #卷积层1 keras.layers.Conv2D(32,kernel_size=5,strides=1,padding=" ...
- 【FishFX】花式撩骚,打造TypeScript易用框架。
· 栗子入手 假设有以下foo数组,数组中每个对象都拥有id,name两个属性,现在需要查找id > 0的对象数量. const foo: Array<{ id: number, name ...