please dont rip this site

PIC Microcontoller Radix Time Math Method


Unpacked BCD to 16 bit binary conversion

Drew Vassallo says:
There's been some discussion about using RTCs lately. Typically, they send/receive in packed BCD. Except for the year, which is 0-99, all of the other variables are within 0-64 BCD.

After briefly searching the PICLIST archives, I couldn't really find any snippets that weren't overkill for this purpose, so I made my own. These are more specific to RTC time conversion and have reduced instruction counts over the "standard" code fragments. If you convert your hours to 12-hour format instead of the 24-hour output format of the RTC, you can use the obvious:

; BCD conversion is limited to "Hours" values less than 16
                movf    Hours, 0
                addlw   0x06
                skpdc
                addlw   -0x06
                movwf   Hours

This can also be used for month and day of the week.

For minutes, seconds, and date, you can use:

; Hex to BCD conversion - limited to 0-99 decimal (0x00-0x63 hex)
; Call with: number to be converted in W
; Returns with: converted BCD number in W
; Registers: Temp, Temp+1 used during conversion
Hex2BCD
		movwf	Temp
		clrw
		btfsc	Temp, 4
		addlw	0x16
		btfsc	Temp, 5
		addlw	0x32
		addlw	0x06
		skpdc
		addlw	-0x06
		btfsc	Temp, 6
		addlw	0x64
		addlw	0x06
		skpdc
		addlw	-0x06
		movwf	Temp+1
		movf	Temp, 0
		andlw	0x0F
		addwf	Temp+1, 0
		skpndc
		addlw	0x06
		addlw	0x06
		skpdc
		addlw	-0x06
		return

See:

Comments:

See also:


file: /Techref/microchip/math/radix/bcdrtc.htm, 3KB, , updated: 2009/5/14 13:41, local time: 2012/2/9 19:57, owner: ADV--A41,
TOP NEW HELP FIND: 
38.107.179.232:LOG IN

 ©2012 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE! / 

<A HREF="http://www.piclist.com/techref/microchip/math/radix/bcdrtc.htm"> PIC Microcontoller Radix Time Math Method </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 
Stepper motors CAN be smooth!
And stepper controllers can be strong and cheap. Roman Black's Linistep stepper controller kits:
o 18th microstep
o Linear smoothing
  o Open source
o Full kit $25!
 
miSim DE is an excellent, portable and powerful IDE for developing PIC applications.
The only consistant, simple to use yet powerful development environment. It simulates real-world devices via virtual component "plugins" (LED,LCD,key,motor,TV,etc) in real time, has a syntax highlighting editor, macro assembler and disassembler. Regular updates and third-party plugins keep this software ahead of any other PIC IDE.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .