Frequency measurement

Thread Starter

RG23

Joined Dec 6, 2010
304
10000 is 0x2710

So I defined AARGB1 as 0x27
AARGB0 as 0x10

I modified the 24 bit by 16 bit division math subroutine to behave as 16bit by 8bit division subroutine as follows

but it didn't work

LOOP501:

RLF AARGB1, F ;and shift in next bit of result
RLF AARGB0, F
RLF REMB0, F
RLF count301, F ;save carry in counter

MOVF count209, W
BTFSS CARRY
INCFSZ count209, W
SUBWF REMB0, W SKPNC ;if no borrow
BSF count301, 0 ;set bit 0 of counter (saved carry)
BTFSC count301, 0 ;if no borrow
GOTO UOK46LL ;jump
MOVF REMB0, W ;read high byte of remainder to W
;to not change it by next instruction
UOK46LL
MOVWF REMB0 ;store high byte of remainder
bcf CARRY ;copy bit 0 to carry
RRF count301, F ;and restore counter
DECFSZ count301, f ;decrement counter
GOTO LOOP501 ;and repeat loop if not zero


RLF AARGB1, F
RLF AARGB0, F
RETURN
 

Markd77

Joined Sep 7, 2009
2,806
The comments say that AARGB0 is the most significant byte so I think you should have
AARGB0=0
AARGB1=0x27
AARGB2=0x10

I'd use one of the 16 bit by 8 bit routines instead of modifying a bigger one, if that's all you need.
 

Thread Starter

RG23

Joined Dec 6, 2010
304
yes now i am getting the correct frequency

but the problem now is I am getting that freq in hex

So, now I need to convert hex to bcd and then to ascii to display on LCD.
 
Top