Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

value multiplied 256

Status
Not open for further replies.
savnik said:
i change the number from 32 to 40

Movlf .32,N ; Init Loop counter
Movlf .40,N ; Init Loop counter

; Bin To BCD conversion ( 32 bit word -> 8 digits )
; Bin in Result, Result+1, Result+2, Result+3
; BCD in BCD3, BCD2, BCD1, BCD0
Bin2BCD
clrc
Movlf .40,N ; Init Loop counter
clrf BCD3 ; Init result
clrf BCD2
clrf BCD1
clrf BCD0

when i measure 99mhz show on lcd 99.000.000
but when i measure 102mhz show on lcd [1] 02.000.000
why ;

hi,
By changing the 'bit counter' value to 40 from 32 you are trying process 5 bytes, but you only have 4 bytes to work with, so you are overflowing the conversion and so you are 'losing' the MSD ie: the "1".
 
hi,
This is a fragment of the code I used to test the Bin2BCD/Disp, it works using the method stated in earlier posts.



Code:
;this is test data to check out the Bin2BCD and DispFreq Subr

;enter with a predivided value 100MHZ by 256 = 390.625
;the 0.625 is 'lost' so the final displayed value is 99,840

start:
	movlw 0x86; load the reg with 390.625 == 100,000/256
	movwf Result+3
	movlw 0x1
	movwf Result+2
	movlw 0x0
	movwf Result+1
	movlw 0x0
	movwf Result

;reposition the reg values == 390 * 256 
	movf Result+2,w
	movwf Result+1	;
	movf Result+3,w
	movwf Result+2
	movlw 0x0
	movwf Result+3

	call Bin2BCD
	call DispFreq; displayed value 99,840
	
lp1: goto lp1

 goto start
 
ericgibbs said:
hi,
By changing the 'bit counter' value to 40 from 32 you are trying process 5 bytes, but you only have 4 bytes to work with, so you are overflowing the conversion and so you are 'losing' the MSD ie: the "1".
Finally i got the code to work right.
I change the 'bit counter' value to 40 from 32 and i add one byte BCD4.
Thank all for the help.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top