'****************************************************************
'* Name : 16F88 TSA5511.BAS *
'* Author : Winate_K *
'* Notice : Copyright © 2012 *
'* : All Rights Reserved *
'* Date : 29/5/2012 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
Device = 16F88
@CONFIG_REQ
@__CONFIG _CONFIG1, cp_off & ccp1_rb0 & debug_off & wrt_protect_off & cpd_off & lvp_off & boden_off & mclr_on & PWRTE_ON & WDT_OFF & INTRC_IO
@__CONFIG _CONFIG2, IESO_OFF & FCMEN_OFF
#define I2C_SCLOUT On
All_Digital = TRUE
TRISA = %11111000
TRISB = %11100000
OSCCON =%01101110
ANSEL = %00011000
Declare LCD_Lines = 2' LCD 4 Line
Declare LCD_DTPin = PORTB.0 'LCD Data Pin
Declare LCD_Interface = 4' LCD Data Pin 4
Declare LCD_RSPin = PORTB.4 'LCD RS Pin
Declare LCD_ENPin = PORTA. 6 'LCD AND Pin
Declare Adin_Res 10
Declare Adin_Tad frc
Declare Adin_Stime = 100
Symbol SDA = PORTA.1' I2C SDA PORTA.1
Symbol SCL = PORTA.0 'I2C Scl PORTA.0
Symbol LED = PORTA.2
Symbol LOO = 0
Symbol Speed = 10
Symbol PWM_SIG = PORTA.7
Dim FREQ_step As Word 'Frequency step
Dim FREQ_khz As Word 'Frequency Khz
Dim FREQ_mhz As Word 'Frequency Mhz
Dim FREQ As Word
Dim F_CONTROL As Word
Dim ADRESS As Byte 'TSA5511 i2c adres
Dim LO As FREQ.LowByte
Dim HI As FREQ.HighByte
Dim Snelheid As Byte ' Velocidad
Dim ToetsHoger As Byte ' subir
Dim ToetsLager As Byte ' bajar
Dim StartSnelheid As Byte ' velocidad de inicio
Symbol quanta = 30 '+Vref = 5V : Quanta=5V/1023*256=1.251
Dim adval As Word
Dim adval1 As Byte
ADCON1 = %11000000 'Right Justify A/D result
Clear
High LED
Cls
Print $fe, 1
Print At 1,1," HELLO "
Print At 2,1," WECOME TO FM PLL "
DelayMS 15000
Print At 1,1," FM TRANSMITTER "
Print At 2,1," *SISAKET PLL V1* "
DelayMS 15000
Loopi:
ADRESS = $C0 'TSA5511 in adres
FREQ_step = ERead 02
If FREQ_step > 0 Then TSA
FREQ_set:
DelayMS 100
FREQ_mhz = (FREQ_step*10/2)//100
FREQ_khz = (FREQ_step*10/2)/100
Print $fe, 1
Print At 1, 1, "Set FM"
Print At 2, 1, "Pw 0.0 W Rf 0.0 W"
DelayMS 100
If PORTB.5 = 1 Then UP_freq
If PORTB.7 = 1 Then DOWN_freq
If PORTB.6 = 1 Then SET_freq
'----------------------- Tsa5511 --------------------------
FREQ = FREQ_step
I2COut SDA,SCL,ADRESS,[HI,LO,$8E,$10]
GoTo FREQ_set
UP_freq:
DelayMS 50
FREQ_step = FREQ_step + 1 'step 5
If FREQ_step > 2160 Then FREQ_step = 1750
GoTo FREQ_set
DOWN_freq:
DelayMS 50
FREQ_step = FREQ_step - 1 'step 5
If FREQ_step < 1750 Then FREQ_step = 2160
GoTo FREQ_set
'--------------------------data ---------------------------
SET_freq:
EWrite 02, [FREQ_step]
DelayMS 200
'----------------------- Tsa5511 --------------------------
TSA:
FREQ = FREQ_step
I2COut SDA,SCL,ADRESS,[HI,LO,$8E,$00] '[HI,LO,$8E,$OO]
DelayMS 200
'----------------------Tsa5511 Control ----------------------
I2CIn SDA,SCL,ADRESS,[F_CONTROL]
If F_CONTROL.6 = 1 Then kitli
FREQ_mhz = (FREQ_step*10/2)//100
FREQ_khz = (FREQ_step*10/2)/100
Print $fe, 1
Print At 1, 1, "Scan FM"
If PORTB.6 = 1 Then FREQ_set
Print At 2, 1, "Pw 0.0 W Rf 0.0 W"
'GoSub PW
GoTo TSA
kitli:
I2COut SDA,SCL,ADRESS,[HI,LO,$8E,$21] '[HI,LO,$8E,$24]
FREQ_mhz = (FREQ_step*10/2)//100
FREQ_khz = (FREQ_step*10/2)/100
Print $fe, 1
Print At 1, 1, "OnAir FM"
If PORTB.6 = 1 Then FREQ_set
GoSub PW
'ADCON0 = %11100101
PW:
Snelheid = ERead 0 '
While 1 = 1
If ToetsHoger = LOO And Snelheid < 250 Then Inc Snelheid
If ToetsLager = LOO And Snelheid > 0 Then Dec Snelheid
PWM PWM_SIG,Snelheid , StartSnelheid
If Snelheid <> ERead 0 Then EWrite 0,[Snelheid]
Print At 2, 1, "Pw 0.0 W Rf 0.0 W"
Adcin 4, adval 'A/D [RA4 AN4]
adval = (adval) */ quanta
If adval < 1000 Then
Print At 2,4," ", Dec1 Dig 2,adval, ".", Dec1 Dig 1, adval
EndIf
If adval > 999 Then
Print At 2,4, Dec1 Dig 3,adval , Dec1 Dig 2,adval , ".", Dec1 Dig 1,adval
EndIf
Adcin 3, adval1 'A/D [RA3 AN3]
adval1 = (adval1) */ quanta
Print At 2, 16, Dec1 Dig 2,adval1, ".", Dec1 Dig 1, adval1
If PORTB.6 = 1 Then FREQ_set
Wend
End