please dont rip this site

PIC Microcontoller Radix Math Method

Binary to BCD unpacked, 24 bit to 4 digits

from Oliver Broad [obroad at TELINCO.CO.UK] Oliver Broad says

The following program is based on the binary to BCD code from the microchip appnote. The method seems odd at first, compared to the more conventional divide-by-10-and-output-the-remainder.

It was originally written to convert data from an AD7714 sigma delta ADC

; Looping version of Binary to BCD converter for 24 bit values
; Code is designed for MPSIM testing, so insert stimuli on ports
; B and B and B, and read out R0,R1,R2,R3.

; Code is based on the fact that a bcd number may be multiplied
; by two by a simple bit shift followed by a BCD fixup. The
; fixup is greatly simplified by performing it BEFORE the shift,
; which is why 3 and 30H are used instead of 6 and 60H.


        LIST P=16C73
        INCLUDE P16C73.INC
        CBLOCK  20H
        R3,R2,R1,R0        ;MUST START ON BINARY XXXXX000.
        COUNT, LBYTE, MBYTE, HBYTE
        ENDC
        ORG     0
MAIN    MOVFW   PORTB
        MOVWF   LBYTE
        MOVFW PORTB
        MOVWF MBYTE
        MOVFW   PORTB
        MOVWF   HBYTE
        CALL    BIN2BCD
        GOTO    MAIN
BIN2BCD MOVLW   18H
        MOVWF   COUNT
        CLRF    R0
        CLRF    R1
        CLRF    R2
        CLRF    R3
        BCF     STATUS,C
        GOTO    BIN2BC2
BIN2L   MOVLW   R3
        MOVWF   FSR
BCDADJ  MOVLW   03H
        ADDWF   INDF,F
        BTFSS   INDF,3
        SUBWF   INDF,F
        MOVLW   30H
        ADDWF   INDF,F
        BTFSS   INDF,7
        SUBWF   INDF,F
        INCF    FSR,F
        BTFSS   FSR,2
        GOTO    BCDADJ
BIN2BC2 RLF     LBYTE,F
        RLF  MBYTE,F
        RLF     HBYTE,F
        RLF R3,F
        RLF     R2,F
        RLF     R1,F
        RLF     R0,F
        DECFSZ  COUNT,F
        GOTO    BIN2L
        RETLW   0
        END


Comments:

See also:


file: /Techref/microchip/math/radix/b2bp-24b8d-ob.htm, 2KB, , updated: 2005/1/9 14:17, local time: 2017/11/19 02:17,
TOP NEW HELP FIND: 
54.80.227.189:LOG IN

 ©2017 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/b2bp-24b8d-ob.htm"> PIC Microcontoller Radix 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?

  PICList 2017 contributors:
o List host: MIT, Site host massmind.org, Top posters @20171119 RussellMc, Van Horn, David, James Cameron, Sean Breheny, alan.b.pearce, IVP, Neil, David C Brown, Bob Blick, Denny Esterline,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .