This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SENSOR-CONTROLLER-STUDIO: sensor controller ram overflow - cc1350

Part Number: SENSOR-CONTROLLER-STUDIO

I'm building a SCS project to talk to a couple of i2c devices and am running up against a RAM overflow issue. Basically my code is too big and was wondering if there are any tricks or workarounds. I can probably trim the code and data to fit, but 1024 words seems pretty small. Is there any way to increase the space available or compiler option to optimize for size? The spec says its 2KB, so assuming 2 byte words, it looks like this is a hard limit.

The bulk of my code is in the initialization and configuration of the i2c devices. I'm thinking of doing 2 separate projects where I initialize the devices in one, then unload that project and swap in the running/data gathering project. Since the individual task in SCS is already split into this "general" model, it seems that there would already be a way to do this (i.e. only load the initialization, execution, or termination sections when needed, to save on RAM). Any thoughts?

  • Hello,

    No, there is no way to increase the memory size. I suggest you optimize the size of the code and minimize the use of variables. maybe reuse some of them ?

    Regards,
    AB
  • What about splitting the initialization code into a separate project from the execution code?

    Basically as follows:
    Load the initialization code onto the sensor controller (with empty execution and termination)
    Configure the i2c sensors from that initialization code
    Unload that project from the sensor controller

    Load the execution code onto the sensor controller (with an empty initialization block)
    Read from the previously configured sensors in the previous project

    Terminate, unload, and repeat....

    Currently, the Initialization, execution, and termination code all live in the same project and need to be loaded into ram at once (when only one of these three is actually being processed at any given time)


    The generated code is not setup for this sort of split operation, so I'd have to do some significant modifications. Ultimately I'll have to optimize my code, but I'm thinking this approach might increase the usable code size.
  • That sounds like a good idea, but I have not tried it before. I am interested in knowing if you get it to work that way. But I do not think you need to keep unloading it and reloading it.

    Maybe only once, after you initialize and when you load the execution code activate the RTC and just run the execution code at a periodic rate?

    AB
  • I'm a long ways from implementing that. I just wanted to see what folks thought about the general concept since it seems a bit hacky. Along those lines, it might be easier to just initialize the device in CCS, and then switch over to the CCS code for the execution cycles. I dont know if the i2c pins can be easily shared between processors like this (i'm still investigating).

    On the optimization front, the following appears to take 18 words of code ram:

        i2cStart();
        i2cTx(I2C_OP_WRITE | (BMP280_ADDRESS<<1));
        i2cTx(BMP280_RESET);
        i2cTx(BMP280_RESET_VAL);
        i2cStop();

    In the documentation it mentions procedure calls and macros. Macros don't appear to save space (I believe they just get expanded by the compiler?). Procedure calls don't seem to be user definable, or at least is indicated not by the documentation. If I had a bunch of calls that look like the above, is there any way to optimize across them? A true procedure sounds like it would be ideal because it would reuse 3 of the 5 lines (which appears to be 10 words according to the code generator). I know... I "might" also be able to write all the addresses and bytes in a single i2c transaction,  but not all devices support that behavior.

    I'm also reading a number of 16 bit values, but those take 2 i2cRxAck's and a shift/addition to cram the 2 bytes into one output. It seems like that would be a good candidate for some code reuse/optimization as well. I already have larger read blocks in a loop, which saves a lot of code words, but I still have to deal with the final nack, so looping is not as efficient when trying to read a 2byte (16bit) piece of data from the i2c device.

  • If you have a code that contains (as an example) 2 tasks and this code is too big, it's possible to split the task into 2 different RAM images . Then you have to give a "source code prefix" in the Project panel. You then have to to a init on one of the images and uninit again before init the second image.