Shop OBEX P1 Docs P2 Docs Learn Events
Problems (I think) with SimpleIDE programs too large — Parallax Forums

Problems (I think) with SimpleIDE programs too large

Hello,
I'm a relative beginner with this, so you'll have to excuse my lack expertise on some of this.
I'm using an Activity Board, programming in PropC in SimpleIDE, and trying to cram as many sensors as possible into it. Sensors/Parts I'm using are
-SD Card
-XBee Radio
-BME680 Environmental Sensor
-LSM9DS1 IMU
-Analog sensors connected to all 4 analog inputs
-2 sensors connected to processor GPIO pins to count pulses (light and particles)
My program works beautifully, collecting data, collating it all to a single string variable, saving that string variable, and transmitting that string variable. The problem comes when I try to add code for the LSM9DS1 IMU. It seems as the code size reaches 30k, issues start to arise with the rest of the system, with certain sensor data no longer showing up, transmitting not working, and variables being gibberish. Code for the IMU works great if I don't try to use it with the rest of the system (such as removing the BME680), the only factor seems to be the code size. So, I have 3 questions:
1. Is my problem only related to code size?
2. I know other people who have 20 of these sensors being controlled by a single (non Propellor) microcontroller, so why is this one struggling to control just a few?
3. Could the problem be related to bloated Parallax libraries, loaded with functions that I don't call? Or do those not contribute to the code size?
Thanks for any help! Would love to learn more deeply about how this works to figure out what the issue is, and if it's possible to continue building larger code with more sensors, or if I've reached the limits of this architecture.

Matt

Comments

  • Wuerfel_21Wuerfel_21 Posts: 5,107
    edited 2020-06-12 19:52
    1. Yes, this could be a code size problem. If the code grows too big, the runtime stack starts overwriting variables and code with no warning. 30K is pretty big.
    I'm not super familiar with SimpleIDE, but IIRC it lets you select which memory model to use. Are you using CMM or LMM? If the latter, try switching to the former to free up memory.

    2. Controlling one sensor vs. 20 of those sensors doesn't make a big difference in code size.

    3. Library functions that are never called are removed by the linker.

    Idk why it fails with this little application code though. One of the libraries might be pulling in a lot of unnecessary code, but I'm not super familiar with the Prop C library landscape, so I can't tell you which. I do know that including float variables anywhere will add a lot of bloat to your program on any microcontroller, try to remove all of those.
  • Thanks, Wuerfel.
    The memory model being used is CMM, with Compiler Type C, and Optimization -Os Size. Those all sound right?
    If I take the floats out, it frees about about 100 bytes, which is helpful but probably peripheral.
    Any other thoughts on why this application is seeming to max out the size, and how to shrink it? Or could this simply be the limits of the propeller chip? Thanks again,
    Matt
  • Wuerfel_21Wuerfel_21 Posts: 5,107
    edited 2020-06-15 18:41
    Oh, you need to replace all calls to the print function with printi to truly get rid of the floating point code. Same for sprint, use sprinti and dprint to dprinti, etc
  • Ah that is helpful, cut some of it out there. Well, thank you for your help. Feel free to drop any more ideas you have on me!
Sign In or Register to comment.