Shop OBEX P1 Docs P2 Docs Learn Events
PropBasic Bug? — Parallax Forums

PropBasic Bug?

FriedVFriedV Posts: 77
edited 2011-10-21 15:39 in Propeller 1
Trying to compile:
' ----------------------------------------------------------------------
' 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) ------------------------------------
    error   var long = 0  'for error signaling, 0 = no error

    tmp1    var long          'those are temp vars for temporary use
    tmp2    var long          'mind they are global
    tmp3    var long
    tmp4    var long
    tmp5    var long

'    tmp6    var long          'more when needed
'    tmp7    var long
'    tmp8    var long
'    tmp9    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

'=======================================================================
and
' ----------------------------------------------------------------------
' File......  Test_SPI_Task.pbas
' Author....  fgvissel  12.10.2011
' ======================================================================

' ----- 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 ------------------------------------------------------
  Dog_Init        CON   10
  Dog_OutChar     CON   11
  Dog_OutString   CON   12
  Dog_Clear       CON   13
  Dog_Line1       CON   14
  Dog_Line2       CON   15
  Dog_Line3       CON   16
  Dog_ClearLine1  CON   17
  Dog_ClearLine2  CON   18
  Dog_ClearLine3  CON   19
  Dog_Set         CON   20

' ----- IO Pins --------------------------------------------------------
  ERR_LED Pin 1 low
  OK_LED  Pin 0 low

' ----- Shared (HUB) Variables (Byte, Word, Long) ----------------------
  Cmd       hub  long = 0   'for command handler

' ----- User Data (DATA, WDATA, LDATA, FILE) ---------------------------

' ----- TASK Definitions -----------------------------------------------
  SPI_Task  TASK
' ----- Local Variables (LONG only) ------------------------------------
  SPI_Cog   var long

' ----- SUB and FUNC Definitions ---------------------------------------

' ======================================================================

PROGRAM Start

Start:
  cogstart SPI_Task, SPI_Cog
  if SPI_Cog = 8 then
    error = 1
    endif

Main:



'###### The End ########################################################
  tmp1 = _FREQ /10        'the loop of life ....
  tmp2 = cnt + tmp1
  If error <> 0 then      'finish with error
    do 
      toggle ERR_LED
      waitcnt tmp2, tmp1
      loop
    else                   'finish ok
      do 
          toggle OK_LED
          waitcnt tmp2, tmp1
          loop
    endif
  '#####################################################################
END

' ----- SUB and FUNC Code ----------------------------------------------

' ----- TASK Code ------------------------------------------------------

TASK SPI_Task  'handles SPI commands for DogM163 and uM-FPU
' ~~~~~ External Libs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  LOAD "C:\work\propeller\propbasic\library\Std.Lib"

' ~~~~~ Conditional Compilation Symbols ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~~~~~ Constants ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~~~~~ IO Pins ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  TASKLED pin 7 low

' ~~~~~ Shared (HUB) Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~~~~~ User Data (DATA, WDATA, LDATA, FILE) ~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~~~~~ Local Variables (LONG only) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~~~~~ SUB and FUNC Definitions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' ~~~~~ Task Code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  tmp1 = _FREQ /5       'slow blink forever      
  tmp2 = cnt + tmp1
  do 
    toggle TASKLED
    waitcnt tmp2, tmp1
    loop

' ~~~~~ Task SUBs and FUNCs Code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
ENDTASK
' ----------------------------------------------------------------------
PropBasic compiles OK, Spin doesn't:

HomeSpun To RAM
Homespun Spin Compiler 0.31d
parsing C:\Work\Propeller\PropBasic\Programs\Test_SPI_Task_LIB.spin
parsing C:\Work\Propeller\PropBasic\Programs\SPI_Task.spin
compiling Test_SPI_Task_LIB.spin
Error: C:\Work\Propeller\PropBasic\Programs\Test_SPI_Task_LIB.spin (119, 46): Unknown symbol VP_Watch
SPI_Task_COG:=SPI_Task.Init(@__DataStart, @VP_Watch)
^
Is this a bug?
Kind regards, Friedrich

Comments

  • BeanBean Posts: 8,129
    edited 2011-10-12 05:05
    Fried,
    Yes that is a bug.
    Here is a corrected version of the compiler (version 1.25).

    Bean
  • FriedVFriedV Posts: 77
    edited 2011-10-12 07:42
    Thanks very much Bean,
    could you please also have a look at PropBasic & Libraries.
    I don't know if I can build programs this way, it is a bit "C"-style.
    Fried
  • BeanBean Posts: 8,129
    edited 2011-10-12 08:02
    Fried,
    I never intended LOAD to be nested. It's not going to work. It will probably stop after 1 level and never return to continue compiling the main program.

    Bean
  • skynuggetskynugget Posts: 172
    edited 2011-10-20 17:56
    hey bean, i think this update caused some problems for me. code is attached, you might recognize it from the viewport thread.
    thank you sir!

    edit: looks like i get the same error with v1.24 as well...last version i have that worked is 1.19, but i havent tried anything in between.

    error:
    ---------- Capture Output ----------
    > "C:\NEWPropBasic\Propellent.exe" /EEPROM "C:\Documents and Settings\stu\Desktop\wxStation\wxRX.spin"
    EVT:501-Compiling: XBEE
    ERR:101-Error compiling file: C:\Documents and Settings\stu\Desktop\wxStation\Xbee.spin
    (Line/Char/Count: 112/41/16)  Undefined symbol.
                      mov           __temp1,CalendarMATH_COG     '  COGSTART CalendarMATH              ' start calculating!
    
    > Terminated with exit code 0.
    
  • BeanBean Posts: 8,129
    edited 2011-10-21 04:47
    I'll check it out.

    Bean
  • BeanBean Posts: 8,129
    edited 2011-10-21 05:46
    I see the problem.

    A task cannot start another task. The addresses of the tasks are held in the main program's COG RAM, so it is not readable from other tasks.
    I could store it in HUB ram, but that will take some work to shuffle everything around.

    I'll put it on the list of things to fix.

    Bean
  • skynuggetskynugget Posts: 172
    edited 2011-10-21 15:39
    thanks again bean! take you time, honestly that was kind of a sloppy work around, i should rethink it. I have this weather box on my desk running all the time, so its an easy thing to test revisions on.
Sign In or Register to comment.