Shop OBEX P1 Docs P2 Docs Learn Events
Auto starting FemtoBasic programs on my StickBasic propeller — Parallax Forums

Auto starting FemtoBasic programs on my StickBasic propeller

Duane C. JohnsonDuane C. Johnson Posts: 955
edited 2011-02-18 10:12 in Propeller 1
To review:
1. My micros are essentially the same as the PropSticks, with no peripheral hardware except for the RS-232 and 32k EEPROM on pins [31..28].
2. While I have run other languages I prefer the FemtoBasic interpreter.
3. No SD card.

I've reviewed the archives and can't see how to autostart a Femto program in my minimalist system.
Yes, I can save a program to the EEPROM and load it again but it doesn't startup on its own.

Am I missing something?
Do I need to change something in FemtoBasic.spin?

What I would like it to do:
1. Start running the saved Femto program after a hard reset or after power up.
2. Drop into command mode after receiving an ESC soft reset.

This might be a separate issue:
I used Phil's nice unload_prop.exe to copy the EEPROM to my PC. This appears to work well for the basic code. However, when unloading the EEPROM that has a saved program in it it generates a .eeprom file. But when using spin to upload to the EEPROM it complains that there is:
"contains data after code space that was not generated by the Propeller Tool. This data will not be displayed or downloaded."
And after the upload this error:
"RAM checksum error on COM5." (COM5 is my current USB RS-232 port.)
I have confirmed Spin actually did not upload to the EEPROM. The old contents is still there. The proof is "forth" was there before the attempted upload and was still there afterward.
Is it possible there are settings in Spin that need to be changed?

Comments

  • BeanBean Posts: 8,129
    edited 2011-02-18 07:54
    I think you have make the first line "1 REM AUTOEXEC" or something like that. It should be in the doc file.

    Bean
  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-18 08:34
    Once upon a time, there was a feature in FemtoBasic where you could do what Bean remembers, but this was removed along the way in the interest of saving code space in the interpreter. There is the ability to automatically run a program from an SD card, but that doesn't help if you don't have an SD card. In the OBEX DongleBasic.spin, there's a block of code in the main method:
    s := 0
       curlineno := -1
       ifnot \mass.mountSDVol(def#spiDO,def#spiClk,def#spiDI,def#spiCS) < 0
          ifnot \mass.openFile(string("autoexec.bas"),"r")
             if (err := \processLoad) <> fEof
                showError(err)
                newprog
             ifnot \mass.closeFile < 0
                \mass.unmountSDVol
             if err == fEof
                s := string("run")
       repeat
    
    This is what checks for a file on an SD card called "autoexec.bas", loads it into memory if present, and executes it. You could try substituting:
    curlineno := -1
       s := string("load:run")
       repeat
    
    This would attempt to do a "LOAD" followed by a "RUN" when FemtoBasic starts up. If there's no saved program, the "LOAD" would get an error and the "RUN" wouldn't be executed. Give it a try. If you forget and there's a saved program in the EEPROM, you can always force it to quit by entering an ESC character on the keyboard.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2011-02-18 09:58
    You da man!

    That worked great!
    Hard reset and power up reset both load and run the program.
    And the soft ESC reset correctly drops to command mode.

    Thanks!

    Are there any restrictions on what can be put into that string?
    How long can it be?
    Such as presetting pins, or settings in the propeller?
  • Mike GreenMike Green Posts: 23,101
    edited 2011-02-18 10:12
    That string is copied to the input line buffer and executed just like any line you'd type in. Looping statements like FOR / NEXT wouldn't work and PAUSE > 10ms won't work properly because of how it's made to be interruptable from the keyboard. I suggest that you use this carefully since this would be executed every time FemtoBasic started up, but wouldn't be executed when you run a Basic program from the command line ("RUN"). It's better to include most of this sort of initialization in the Basic program itself. Have a look in the "doline" method to see what gets reset when a Basic program stops.
Sign In or Register to comment.