PropBasic & Libraries
Hi,
doesn't PropBasic support nested libraries?
This code works ok, no errors from PropBasic neither from Homespun:
Std.Lib:
Std.Lib as before,
Dog.Lib:
HomeSpun To RAM
Homespun Spin Compiler 0.31d
parsing C:\Work\Propeller\PropBasic\Programs\DogM162.spin
Error: C:\Work\Propeller\PropBasic\Programs\DogM162.spin (106, 19): Unexpected mov
mov __temp1,MOSI ' shiftout MOSI, MCLK, MSBFIRST, __param1
^
Where is my error?
Thanks, Friedrich
doesn't PropBasic support nested libraries?
This code works ok, no errors from PropBasic neither from Homespun:
Std.Lib:
' ----------------------------------------------------------------------
' File...... Std.lib
' Author.... fgvissel 10.10.2011
' Library Std, Delay Subs & idx vars
' ======================================================================
' ----- External Libs --------------------------------------------------
' ----- Conditional Compilation Symbols --------------------------------
' ----- Constants ------------------------------------------------------
' ----- IO Pins --------------------------------------------------------
' ----- Shared (HUB) Variables (Byte, Word, Long) ----------------------
' ----- User Data (DATA, WDATA, LDATA, FILE) ---------------------------
' ----- TASK Definitions -----------------------------------------------
' ----- Local Variables (LONG only) ------------------------------------
t1 var long 'those are temp vars for temporary use
t2 var long 'mind they are global
t3 var long
t4 var long
t5 var long
' ----- SUB and FUNC Definitions ---------------------------------------
DelayMS SUB 1
DelayUS SUB 1
'{$CODE}
' ----- SUB and FUNC Code ----------------------------------------------
SUB DelayMS
pause __param1
ENDSUB
SUB DelayUS
pauseus __param1
ENDSUB
'{$TASKS}
'------ Task Code ------------------------------------------------------
'=======================================================================
Main Program:' ----------------------------------------------------------------------
' File...... DogM162.pbas
' Author.... fgvissel 09.10.2011
' for Propeller with 6,26 MHz X-tal
' Uses only Std.Lib, Dog Subs local
' ======================================================================
' ----- Device Settings ------------------------------------------------
DEVICE P8X32A, XTAL1, PLL16X
XIN 6_250_000
' ----- External Libs --------------------------------------------------
'{$ifndef StdLib}
'{$define StdLib}
LOAD "C:\work\propeller\propbasic\library\Std.Lib"
'{$endif}
' ----- Conditional Compilation Symbols --------------------------------
' ----- Constants ------------------------------------------------------
' ----- IO Pins --------------------------------------------------------
D0 Pin 0 'Live signal
RS Pin 20 High '<--> EA DogM16x Pin 39
CSB Pin 21 High '<--> EA DogM16x Pin 38
MOSI Pin 23 Low '<--> EA DogM16x Pin 28
MCLK Pin 22 High '<--> EA DogM16x Pin 29
' ----- Shared (HUB) Variables (Byte, Word, Long) ----------------------
' ----- User Data (DATA, WDATA, LDATA, FILE) ---------------------------
' ----- TASK Definitions -----------------------------------------------
' ----- Local Variables (LONG only) ------------------------------------
delta VAR LONG
target VAR LONG
counter VAR LONG
' ----- SUB and FUNC Definitions ---------------------------------------
Dog_OutChar SUB 1
Dog_OutString SUB 1
Dog_Init_162 SUB
' ======================================================================
PROGRAM Start
Start:
Dog_Init_162
Main:
Dog_OutString "0123456789ABCDEF"
low RS 'Command
Dog_OutChar $C0 'set RAM address $40
Dog_OutString "Line 2"
delta = _FREQ /10
target = cnt + delta
do
toggle D0
waitcnt target, delta
loop
END
' ----- SUB and FUNC Code ----------------------------------------------
SUB Dog_OutChar
shiftout MOSI, MCLK, MSBFIRST, __param1
DelayUS 50
ENDSUB
SUB Dog_OutString
t1 = __param1 'hub address of string
t2 = len __STRING(t1)
high RS 'data
t2 = t2 - 1
for t3 = 0 to t2
RDBYTE t1, t4
Dog_OutChar t4
inc t1
next
ENDSUB
SUB Dog_Init_162
DelayMS 75 'Init DOGM-162 LCD for 5V, 8bit SPI operation
low CSB 'Chip select, Sync with Propeller
low RS 'Command mode for LCD
Dog_OutChar $38
Dog_OutChar $39
Dog_OutChar $1C
Dog_OutChar $74
Dog_OutChar $52
Dog_OutChar $69
DelayUS 250
Dog_OutChar $0F
Dog_OutChar $01 'Clear Display
DelayMS 2 'End of Init
ENDSUB
' ----- TASK Code ------------------------------------------------------
' ----------------------------------------------------------------------
But if I build another library for the dog LCD code:Std.Lib as before,
Dog.Lib:
' ----------------------------------------------------------------------
' File...... Dog.lib
' Author.... fgvissel 10.10.2011
' Library Dog, Driver for EA_DogM16x LCD
' Uses Std.Lib
' ======================================================================
' ----- External Libs --------------------------------------------------
'{$ifndef StdLib}
'{$define StdLib}
LOAD "C:\work\propeller\propbasic\library\Std.Lib"
'{$endif}
' ----- Conditional Compilation Symbols --------------------------------
' ----- Constants ------------------------------------------------------
' ----- IO Pins --------------------------------------------------------
RS Pin 20 High '<--> EA DogM16x Pin 39
CSB Pin 21 High '<--> EA DogM16x Pin 38
MOSI Pin 23 Low '<--> EA DogM16x Pin 28
MCLK Pin 22 High '<--> EA DogM16x Pin 29
' ----- Shared (HUB) Variables (Byte, Word, Long) ----------------------
' ----- User Data (DATA, WDATA, LDATA, FILE) ---------------------------
' ----- TASK Definitions -----------------------------------------------
' ----- Local Variables (LONG only) ------------------------------------
' ----- SUB and FUNC Definitions ---------------------------------------
Dog_OutChar SUB 1
Dog_OutString SUB 1
Dog_Init_162 SUB
'{$CODE}
' ----- SUB and FUNC Code ----------------------------------------------
SUB Dog_OutChar
shiftout MOSI, MCLK, MSBFIRST, __param1
DelayUS 50
ENDSUB
SUB Dog_OutString
t1 = __param1 'hub address of string
t2 = len __STRING(t1)
high RS 'data
t2 = t2 - 1
for t3 = 0 to t2
RDBYTE t1, t4
Dog_OutChar t4
inc t1
next
ENDSUB
SUB Dog_Init_162
DelayMS 75 'Init DOGM-162 LCD for 5V, 8bit SPI operation
low CSB 'Chip select, Sync with Propeller
low RS 'Command mode for LCD
Dog_OutChar $38
Dog_OutChar $39
Dog_OutChar $1C
Dog_OutChar $74
Dog_OutChar $52
Dog_OutChar $69
DelayUS 250
Dog_OutChar $0F
Dog_OutChar $01 'Clear Display
DelayMS 2 'End of Init
ENDSUB
'{$TASKS}
'------ Task Code ------------------------------------------------------
'=======================================================================
Main Program:' ----------------------------------------------------------------------
' File...... DogM162.pbas
' Author.... fgvissel 09.10.2011
' for Propeller with 6,26 MHz X-tal
' Uses Dog.Lib
' ======================================================================
' ----- Device Settings ------------------------------------------------
DEVICE P8X32A, XTAL1, PLL16X
XIN 6_250_000
' ----- External Libs --------------------------------------------------
'{$ifndef DogLib}
'{$define DogLib}
LOAD "C:\work\propeller\propbasic\library\Dog.Lib"
'{$endif}
' ----- Conditional Compilation Symbols --------------------------------
' ----- Constants ------------------------------------------------------
' ----- IO Pins --------------------------------------------------------
D0 Pin 0 'Live signal
' ----- Shared (HUB) Variables (Byte, Word, Long) ----------------------
' ----- User Data (DATA, WDATA, LDATA, FILE) ---------------------------
' ----- TASK Definitions -----------------------------------------------
' ----- Local Variables (LONG only) ------------------------------------
delta VAR LONG
target VAR LONG
counter VAR LONG
' ----- SUB and FUNC Definitions ---------------------------------------
' ======================================================================
PROGRAM Start
Start:
Dog_Init_162
Main:
Dog_OutString "0123456789ABCDEF"
low RS 'Command
Dog_OutChar $C0 'set RAM address $40
Dog_OutString "Line 2"
delta = _FREQ /10
target = cnt + delta
do
toggle D0
waitcnt target, delta
loop
END
' ----- SUB and FUNC Code ----------------------------------------------
' ----- TASK Code ------------------------------------------------------
' ----------------------------------------------------------------------
PropBasic compiles ok, but homespun complains:
HomeSpun To RAM
Homespun Spin Compiler 0.31d
parsing C:\Work\Propeller\PropBasic\Programs\DogM162.spin
Error: C:\Work\Propeller\PropBasic\Programs\DogM162.spin (106, 19): Unexpected mov
mov __temp1,MOSI ' shiftout MOSI, MCLK, MSBFIRST, __param1
^
Where is my error?
Thanks, Friedrich

Comments
I just looked at the spin file and the dog.lib subroutines are there twice.
If I delete the first set all is well. I have attached all the test files.
TestLib.zip
Cheers, Fried