Prescaler - VU3CNS 16F628A Frequency Counter

Discussion group on micro controllers, programming, and related..

Prescaler - VU3CNS 16F628A Frequency Counter

Postby timetec » Thu Jul 16, 2015 6:20 am

Hi everyone

Have compiled the source code for C V Niras's (VU3CNS) / FC0.51 1x16 line LCD Counter with new IF offset values - it works very well :)

I've now added a /10 prescaler to extend it's working range to approx 500Mhz - in this case using a Motorola MC12080.
Obviously, the IF offset values must be entered at 1/10 of their original value - eg 1.07000 instead of 10.7000 Mhz
This is no big deal (just annoying lol), but I need to move the decimal point one place to the right to get the correct frequency reading on the LCD....

So, as an example, using a 66.667MHz HCXO oscillator as an input and the MC12080 /10 prescaler, I get 6.6667Mhz (as expected) - but wrong (10x too low)

So, how do I move the decimal point one place to the right on the display so it reads correctly as 66.667 Mhz ?

Perhaps there is an alteration to the code that can correct both the decimal point placement AND the IF offset issue together when using a /10 prescaler?

Below is a snippet of the code I think needs to be altered :

; Routine for single line displays
DISPLAY_FREQ: BCF NEGATIVE ; Clear the negative flag.
BTFSS ARG0,7 ; Is ARG2 a negative number?
GOTO DISP_FREQ ; N. Just continue.
BSF NEGATIVE ; Y. Set the negative flag.
CALL NEG_ARG0 ; (1) Convert it to a + number.
DISP_FREQ: CALL BIN_TO_DEC ; (2) Convert the number to ASCII decimal.
; CALL SET_ARG1 ; (1) Set FSR = ARG1_8, COUNT_1 = 9.
MOVLW D'7' ;
MOVLW H'80' ; Position the cursor, line 1 pos 1.
DISP_LOOP: MOVF INDF,W ; Get char pointed to by FSR.
CALL LCD_CHR ; (2) Display the char.
MOVLW D'5' ;
SUBWF COUNT_1,W ; Y. Is it time to insert a decimal point?
CALL LCD_CHR ; (2) Y. Display a decimal point.
NO_DP: INCF FSR,F ; Inc the pointer.
DECFSZ COUNT_1,F ; All done ?
GOTO DISP_LOOP ; N. Continue.

Many thanks for any help! :mrgreen: Richard
Posts: 1
Joined: Thu Jul 16, 2015 5:43 am

Re: Prescaler - VU3CNS 16F628A Frequency Counter

Postby vu3cns » Thu Jul 16, 2015 7:20 am

timetec wrote:
Code: Select all
DISP_LOOP:      MOVF    INDF,W            ; Get char pointed to by FSR.
                CALL    LCD_CHR            ; (2) Display the char.
                MOVLW   D'5'            ;

I am not sure, but try to change D'5' to D'6' or D'4' to move decimal point.
Posts: 289
Joined: Sat Jun 14, 2003 12:00 am
Location: Calicut

Return to Micro controllers

Who is online

Users browsing this forum: No registered users and 2 guests