Code error
: 25 mar 2020, 5:58
Hi Everyone,
I try to modified below code, but i am getting an error, that below code not finish compile.
Could someone here help me to solved what the problem, i am new in basic compiler.
Thank you.
Wea.
I try to modified below code, but i am getting an error, that below code not finish compile.
Could someone here help me to solved what the problem, i am new in basic compiler.
Code: [Zaznacz cały] [Rozwiń/Zwiń]
- $Regfile="m8def.dat"
- $Crystal=8000000
- $hwstack=40
- $swstack=40
- $framesize=40
- Rem Configuration of LCD display
- Config Lcd = 20 * 2 '2 rows x 20 chars
- Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portd.7 , Db6 = Portd.6 , Db7 = Portd.5 , Rs = Portb.2 , E = Portb.1
- Cursor Off
- Cls
- Rem Configuration of ADC
- Config Adc = Single , Prescaler = Auto
- Rem Declarations of variables
- Dim Uref As Word
- Dim Uf As Long
- Dim Ur As Long
- Dim Adjust As Word
- Dim Swr1 As Long
- Dim Swr2 As Long
- Dim Swr As Single
- Dim Swr$ As String * 3
- Dim X As Single
- Dim Pwr As Single
- Dim Scale(3) As Byte
- Dim X_scale As Byte
- Dim Scale_$(3) As String * 4
- Dim E_scale As Eram Byte
- Dim Multiply As Byte
- Const Row = " "
- Rem Config and setting ports
- Config Pinc.6 = Input
- Config Pinc.5 = Input
- Config Pind.0 = Output
- Config Pinc.0 = Input
- Config Pinc.1 = Input
- Config Pinc.2 = Input
- Set Portc.6
- Set Portc.5
- Set Portc.4
- Set Portd.0
- Rem show scale
- X_scale = E_scale
- GoSub Show_scale
- Rem MAIN LOOP
- Do
- GoSub Read_adc
- GoSub Calculate_pwr
- GoSub Show_pwr
- GoSub Calculate_swr
- GoSub Show_swr
- Waitms 100
- Debounce Pinc.5 , 0 , Scale_sub , Sub
- Loop
- Rem ===============================
- Rem ==== SUBS =================
- Rem ===============================
- Rem Read ADCs
- Read_adc:
- Start Adc
- Uref = Getadc(1)
- Uf = Getadc(0)
- Ur = Getadc(2)
- Adjust = Getadc(3) 'Calculate variable "Adjust"
- Adjust = Adjust * 10
- Adjust = Adjust + 54000
- Stop Adc
- Return
- Rem ===Calculate SWR====
- Calculate_swr:
- Swr1 = Ufi + Ur
- Swr2 = Ufi - Ur
- Swr = Swr1 / Swr2
- Swr$ = Str(Swr)
- Swr$ = Left(Swr$, 3)
- Swr = Log10(Swr) 'calculate SWR bargraph
- Swr = 20 * Swr
- Swr = Round(Swr)
- If Swr > 15 Then
- Swr = 15
- End If
- Return
- Rem ===Show SWR=========
- Show_swr:
- Locate 2, 1
- Lcd Row
- Locate 2, 1
- For X = 1 To Swr 'show SWR bargraph
- Lcd "="
- Next
- Lcd ">" ; Swr$
- Return
- Rem ===Calculate PWR===============
- Calculate_pwr:
- Uf = Uf - Uref
- Ur = Ur - Uref
- Pwr = Uf ^ 2
- Pwr = Pwr / Adjust
- If Pwr < 0.05 Then
- End If
- Pwr$ = Str(Pwr)
- Pwr$ = Left(Pwr$, 3)
- Pwr = Multiply * Pwr 'calculate PWR bargraph
- Pwr = Round(Pwr)
- Return
- Rem ===Show PWR============
- Show_pwr:
- Locate 1, 1
- Lcd Row
- Locate 1, 1
- Lcd Pwr$
- Return
- Rem ===Switch scale of PWR bargraph ========
- Scale_sub:
- X_scale = E_scale
- Incr X_scale
- If X_scale > 3 Then
- X_scale = 1
- End If
- GoSub Show_scale
- Return
- Rem ===Show PWR bargraph scale ============
- Show_scale:
- Scale_$(1) = "500 W"
- Scale_$(2) = "250 W"
- Scale_$(3) = "50 W"
- Scale(1) = 1
- Scale(2) = 4
- Scale(3) = 10
- Multiply = Scale(x_scale)
- E_scale = X_scale 'save PWR bargraph scale into eeprom
- Cls
- Locate 1, 4
- Lcd "BARTEK: " ; Scale_$(x_scale) 'range of bargraf
- Wait 3
- Return
- End
Thank you.
Wea.