- Blog entry posted in 'Uncategorised', April 27, 2009.
procedure intro is -- INTROTEXT
HD44780_line1
hd44780 = " " hd44780 = " " hd44780 = " " hd44780 = "i"
hd44780 = " " hd44780 = "o" hd44780 = "s" hd44780 = " "
hd44780 = " " hd44780 = " " hd44780 = "v" hd44780 = "v"
hd44780 = "a" hd44780 = " " hd44780 = " " hd44780 = " "
HD44780_line2
hd44780 = " " hd44780 = " " hd44780 = " " hd44780 = " "
hd44780 = " " hd44780 = "F" hd44780 = "M" hd44780 = " "
hd44780 = "P" hd44780 = "L" hd44780 = "L" hd44780 = " "
hd44780 = " " hd44780 = " " hd44780 = " " hd44780 = " "
delay_2s
hd44780_clear
end procedure -- INTROTEXT
-- ---------------------------------------------------------------
procedure pll is
HD44780_line2
print_decimal_1( hd44780 , derde , " " )
print_decimal_2( hd44780 , eerste , "0" )
hd44780 = "."
print_decimal_1( hd44780 , tweede , "0" )
hd44780 = " " hd44780 = "M" hd44780 = "H" hd44780 = "Z"
i2c_write_2 ( tsa5511 , rhi , rlow )
delay_10ms
end procedure
-- ***************************************************************
-- ***************************************************************
Procedure Mul16x8U(byte in out Aa0, byte in out Aa1, byte in out Aa2, byte in Ba0) is
Var byte tempb0,tempb1,loopcount
const _C = 0
Aa0 = Aa1 -- Right justify ==> Left justify
Aa1 = Aa2
assembler
local LOOPUM1608A, LUM1608NAP, LOOPUM1608, LUM1608NA
CLRF Aa2 -- clear partial product
MOVF Aa0,W
MOVWF TEMPB0
MOVF Aa1,W
MOVWF TEMPB1
MOVLW 0x08
MOVWF LOOPCOUNT
LOOPUM1608A: RRF Ba0, F
BTFSC STATUS,_C
GOTO LUM1608NAP
DECFSZ LOOPCOUNT, F
GOTO LOOPUM1608A
CLRF Aa0
CLRF Aa1
RETLW 0x00
LUM1608NAP: BCF STATUS,_C
GOTO LUM1608NA
LOOPUM1608: RRF Ba0, F
BTFSS STATUS,_C
GOTO LUM1608NA
MOVF TEMPB1,W
ADDWF Aa1, F
MOVF TEMPB0,W
BTFSC STATUS,_C
INCFSZ TEMPB0,W
ADDWF Aa0, F
LUM1608NA: RRF Aa0, F
RRF Aa1, F
RRF Aa2, F
DECFSZ LOOPCOUNT, F
GOTO LOOPUM1608
RETLW 0x00
end assembler
end procedure
-- ----------------------------------------------------------------------
procedure reken is
-- eerste (MHz) x 10, dan tweede (kHz) erbij optellen
-- dan resultaat x2 en naar pll
flow = eerste -- flow = MHz'en
mul16x8u ( fhi, flow ,dummy, 0x0A ) -- eerste x 10
-- --- tweede + f (hi, low) = r(hi,low) ---------------------------------
assembler -- khz'en optellen bij
clrf rlow -- resultaat van mul16x8u
clrf rhi -- -----------------------
movf flow , w
addwf tweede, w
movwf rlow
--
movf fhi, w
btfsc status , 0
addlw 0x01
--
addwf dummy, w
movwf rhi
end assembler
mul16x8u ( dummy , rhi, rlow , 0d02 ) -- mul16x8u x 2
end procedure
-- ++++++++++++++++++++++++++++++++++++freq saven in eeprom++++++++++
procedure saved is -- 5 --
eeprom_put ( 0x01 , derde )
eeprom_put ( 0x02 , tweede )
eeprom_put ( 0x03 , eerste )
eeprom_put ( 0x04 , cp )
reken pll delay_10ms(5)
teller = 5
end procedure
-- ----------------------------------- mhz up/down--------------------
procedure mhz is -- 2--
pll
hd44780_line1
hd44780 = "s" hd44780 = "e" hd44780 = "t" hd44780 = " "
hd44780 = "M" hd44780 = "H" hd44780 = "Z" hd44780 = " "
if down then potin = potin - 1 end if -- down
if up then potin = potin + 1 end if -- up
if potin < 0 then potin = 0 end if
if potin > 255 then potin = 255 end if
eerste = 0 + potin
if eerste >= 0 & eerste < 100 then derde = 0 end if
if eerste > 99 & eerste < 200 then derde = 1 end if
if eerste > 199 & eerste <= 255 then derde = 2 end if
delay_100ms (1)
end procedure