The program below compiles and runs just fine in v2.2.1.1 but generates compiler errors if compiled with v5.3.1.0. Apparently the DIG statement is the offender, but it's a legal usage as far as I can tell.
The program simply reads an A/D pin on an ATOM28 module, and lights an LED if result is below a threshold.
Can anyone shed any light?
Code:
'******************************************************************************
'
'This program is the low battery voltage and runs on the Atom microcontroller
'from BasicMicro Inc.
'
'******************************************************************************
'
'
'******************************************************************************
'
'
'******************************************************************************
'
'Define variables & constants
'
'******************************************************************************
'
i var word 'for-next loop variable
x var byte '
Temp1 var word 'General purpose variable
Temp2 var word 'General purpose variable
Temp3 var sword 'General purpose variable
'
A2D_Clk con 2 '
A2D_sample var long '
VBAT var long 'adjusted battery measurement
VBAT_INT VAR BYTE 'integer portion of VBAT variable
VBAT_DP VAR BYTE 'decimal point portion of VBAT variable
'
'******************************************************************************
'
'Assign pin aliases (Note: 1st character cannot be numeric)
'
'******************************************************************************
'
KbdData con P0 '
SCL con P1 '
KbdInt con P2 '
SDA con P3 '
KbdAck con P4 '
BalAft con P5 '
TrSensor con P6 '
BalFwd con P7 '
'
LCD_TX con P8 '
ClkInt con P9 '
MrSensor con P10 '
Wheels con P11 '
Alert_LED con P12 '
COP_LED con P13 '
W1 con P14 '
SpareIO con P15 '
'
'A2d pin con ax0 'A2D input pin
RPM_horn con ax1 'RPM horn output
TP2 con ax2 'gen purpose test point
SeatSensor con ax3 'seat sensor input
'
INPUT AX0 'VBAT ANALOG INPUT
OUTPUT AX2 'LOW ROTOR RPM HORN
'
'******************************************************************************
'
'Establish initial variables. Note: Number of sensors exceeds number of display
'pages. Some display pages have no specific sensor (SLIP), and some sensors have
'no uniquely associated display page (Seat Sensor).
'
'******************************************************************************
'
'
'******************************************************************************
'
'******************************************************************************
'
Low RPM_horn '
Low SpareIO '
Low KbdAck '
Low SpareIO 'diag use only
Low SCL '
'
'******************************************************************************
'
'
'******************************************************************************
'
Main_Loop:
'
'
'******************************************************************************
'
'Check parameters
'
'******************************************************************************
'
gosub CheckVbat 'Check battery condition
'
goto Main_Loop 'resume battery check loop
'
End ' Done. End program
'
'******************************************************************************
'
'Check Battery voltage
'
'******************************************************************************
'
CheckVbat:
Adin AX0,A2D_Clk,AD_RON,A2D_sample
A2D_sample = A2D_sample * 100
VBAT = A2D_sample / 595
'
'Parse into integer and decimal point parts for easy LCD display
'
VBAT_INT = VBAT /10
VBAT_DP = VBAT DIG 0
serout s_out,i2400, ["VBAT is ",dec VBAT_INT,".",dec VBAT_DP,13]
pause 250
'
if VBAT_INT > 12 then CheckVbat2 'Vbat good if Vbat_Int is 13 or above
'
if VBAT_INT = 12 and VBAT_DP > 5 THEN CheckVbat2 ' Vbat still good if greater than 12.5 volts
'
high RPM_horn 'batt low, keep horn on while batt low
serout s_out,i2400, ["VBAT is low at ",dec VBAT_INT,".",dec VBAT_DP,13,13]
pause 250
return
'
CheckVbat2:
low RPM_horn 'batt good, keep horn off
return