Shop OBEX P1 Docs P2 Docs Learn Events
How many LONG(s) in a TASK statement? — Parallax Forums

How many LONG(s) in a TASK statement?

This is the error I get, and the program/code still loads successfully...
LCD_1.spin - Error at (698,8) PC exceeds cog memory by 6 longs
FIT 49
2
I have in that TASK in PROBBASIC, 14 LONG variables, and alot of DATA STATEMENT(s) in that TASK to run my serial LCD display.

Thanks..DennO

Comments

  • The practical limit of a Cog (and therefore a TASK) is 496 LONGs, if I am not mistaken. This includes the executable code, variables, and data. Some additional details are in the "Cogs" section of the Propeller Manual.
  • BeanBean Posts: 8,129
    Data resides in hub memory, so that is not it.
    Variables and code must fit in 496 longs.
    You say you only have 14 long vars, so it must be code size.

    Try to optimize your code for that task or...

    You can make any TASK use LMM by just adding "LMM"

    TASK LCD_1

    change to

    TASK LCD_1 LMM

    Of course LMM code only runs about 1/4 as fast...

    Bean
  • dennodenno Posts: 223
    edited 2018-10-06 13:37
    OK, Bean, and Hatallica, thank you for your input. Bean, I would like to add that I am enjoying playing around with PROPBASIC. I do not have any real project to embed the FLIP into yet, but I can really see how this will keep the "Basic Stamp" coding going, as the PROPBASIC probably isn't as good as SPIN, but it is, for me easier to work with, with the exception of using MATH operators. In Basic, you can put more then one operator on a single line, where as PROPBASIC requires only one operator per line...just takes more lines of code. Unless, Bean you have a better idea...the following is what I have to do, to break up a voltage reading for display, with the decimal point in place. (Volts, decimal, tenth of a volt, hundredth of a volt...)
       voltChannel = %11001  ''CH1  to measure input voltage 12 VOLT measure...MCP3204
       GOSUB getADCdata
       MCPValue = MCPValue * 3   'voltage divider...3-10K resistors in series to make the measured value of the MCP3204 less then 5V's.
       WRLONG MCPValueLocation, MCPValue
       VOLT_12v = MCPValue/819      
       VOLTtenth_12v = MCPValue//819 
       VOLTtenth_12vx10 = VOLTtenth_12v * 10
       VOLTtenth_12v = VOLTtenth_12vx10 / 819
       VOLThunds_12v = VOLTtenth_12vx10 // 819
       VOLThunds_12v = VOLThunds_12v * 10
       VOLThunds_12v = VOLThunds_12v / 819
       WRLONG volt_location_12v, VOLT_12v
       PAUSE 50
       WRLONG tenth_location_12v, VOLTtenth_12v
       PAUSE 50
       WRLONG hunds_location_12v, VOLThunds_12v
       PAUSE 50
    
     SUB getADCdata
       LOW ADC_CS ' Enable MCP3204
       PAUSEUS 100
       SHIFTOUT ADC_Din, ADC_Clk, MSBFIRST, voltChannel\5 ' Select CH0, Single-Ended
       SHIFTIN ADC_Dout, ADC_Clk, MSBPOST, MCPValue\13 ' Read ADC
       HIGH ADC_CS ' Disable ADC
       LOW ADC_Clk
     RETURN 
    

    Interesting to note, Bean, the above code has a GOSUB in it. Actually, in that TASK, I have 3 GOSUBS to the getADCdata. Just changing the channel for a different measurement reading on another device. This code runs. But if I put a DIFFERENT GOSUB inside that same TASK, with a different name, I get the error message that SUBS or FUNCTIONS cannot be nested. I have really tried several different approaches, and still get the same error even using your advice in previous posts/threads.

    Presently, I have all eight COG(s) running with various TASK(s), (1)room temperature,(2) sonic distance (short distance using Parallax's transducer, (3)using another more powerful sonic transducer (out to 20 feet),(4)LED blink, (5), another LED blink,(6)variable voltage measurement(0 to 5 volts), (7)and yet another voltage measurement (12 volt supply), and the last COG is dedicated to running the LCD display, which is a SERIAL display (4X20). I am sending all the above data through the HUB to be displayed, along with the location and DATA info to be displayed...being able to send a line of DATA to the display with one SEROUT command is really helpful. And that is the COG that the error message says I do not have enough room in memory. So, I will try the LLM mode on that one...speed is not to important..

    ADDENDUM:...Bean, I added LMM to the one TASK that was "overloaded", and that cleared up the error message. Thanks again

    DennO
Sign In or Register to comment.