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.

CCS/CC2640R2F: Switching between 2 Sensor Controller Projects in 1 CCS BLE Project

Part Number: CC2640R2F

Tool/software: Code Composer Studio

Hi,

The goal of my project is to be able to run two significantly different functionalities on the same chip, configurable via an attribute (and then with a power-reset). I currently have made 2 Sensor Controller projects, and so now I want to integrate in a way with CCS so that the source code for both is included, and depending on which project number is specified in non-volatile memory (modifiable via bluetooth), it includes the relevant SCIF files. 

My first attempt at this was to create separate directories for each within my project and then include that certain directory based on an if statement that checks memory, but this actually did not work because whenever I would try to build it, it would give me errors of "__ has already been defined" for all the sensor controller functions (maybe by building it gets rid of my custom directories that separate the two project files?). I'm not too familiar with the build settings, but is there a way to build both in a way that still compiles and can include files in one directory or another? 

It's also worthy to note that I don't need to switch projects while chip is on, I can certainly do a power reset after changing which project to use so that the right files are included.

P.S. I've noticed that there's actually only 3 files in the Sensor Controller outputted files that actually are different from each other for the two projects: scif.h, scif.c, and sce.lst. The rest are identical and I can keep one of their copies, but these three files are different between the projects so they're the ones I need to include based on which project is specified.

Thanks!

Ali

  • Hi Ali,

    Is the goal to combine the two projects so that you only have one project that has the code for both? And the required source for a particular build depends on a value stored in flash on the device?

    If so, what comes to mind is to have one project with two specific build configurations. Each configuration would specify a specific set of source files and build options that are specific to a specific "project number"

    I'm still a bit confused on the use case. I guess you would have to read the "project number" value from flash on the target (how? Using CCS to read memory?) and once you know the number, you can then use the associated build configuration for that number... ? Does that make sense?

    Thanks

    ki 

  • Hi Ki,

    Thank you for your response. 

    • "Is the goal to combine the two projects so that you only have one project that has the code for both? And the required source for a particular build depends on a value stored in flash on the device"


    Yes, exactly. I'd like to combine two Sensor Controller (SC) Projects into 1 Simple Peripheral project, and be able to use either SC project based on value stored in flash on the device. But to clarify, the goal is for this to all be downloaded onto the Peripheral so that the CC2640R2F is able to switch between SC project and SC project 2 based on a BLE characteristic value that I store to memory. So for example the flow would be the chip is running SC project 1, then I write Characteristic Value from my phone, this new value gets stored in memory, then next time the chip power resets it will be running SC project 2. Hope that makes sense.

    • If so, what comes to mind is to have one project with two specific build configurations. Each configuration would specify a specific set of source files and build options that are specific to a specific "project number


    I think this is different. See point above. My goal is to change the setup of the build so that two SC projects can coexist (maybe in different directories?) in one built project, so then in the SimplePeriphal.C i could do something like

    if(memory == 1)

        #include SCproject1/scif.h

    else 

        #include SCproject2/scif.h

    Hope that clarified things a bit. Right now when I try this the project fails to compile because it gives redefinition error for all my methods in scif.h

    Thanks!

    Ali

  • Ali Mirzazadeh said:
    But to clarify, the goal is for this to all be downloaded onto the Peripheral so that the CC2640R2F is able to switch between SC project and SC project 2 based on a BLE characteristic value that I store to memory. So for example the flow would be the chip is running SC project 1, then I write Characteristic Value from my phone, this new value gets stored in memory, then next time the chip power resets it will be running SC project 2. Hope that makes sense.

    From my long experienced using Sensor Controller, what you want to do is not ideal. If you want to use another Sensor Controller project during run time then you need to re-init the Sensor Controller, which means you need to re-init the device.

    -kel

  • Hi Kel, by re-init do you just mean to turn off and back on? If so, that is quite OK. I don't need the other project immediately. What do you do in order to achieve this?

    Thanks!

    Ali

  • Hi,

    I have a CCS project with 2 Sensor Controller Program files, which is stored at 2 separate folders at CCS Project. The other not used Sensor Controller folder is excluded at build. Also I set the include options for the Sensor Controller folder in use.

    The reason for this is because the CCS project is configurable to work for the Launchpad and a custom board.

    -kel

  • Hi Kel,

    Thank you for the quick response. I see. This is I think almost exactly what I am trying to do. I have 2 Questions:

    1. How did you do excluding from build? I made two directories in my project folder in the workspace, but the program seemed to be trying to build both even though I put the include to a specific director....I have a feeling it might be because the build settings automatically build everything in the main project folder regardless of included or not? How did you setup your directories to get it to correctly exclude from build?

    2. Correct me if I'm wrong, but what I understand with your method is that it is not possible to switch after the program is built and launched, the switch can only be done with setting an include option in CCS? If so, do you know of a way to take this a step further and build both SC projects but exclude/include one or the other at device power-up? If not, your way is the second best option for me but it would be ideal if it could be done like so.

    Thanks so much!

    Ali

  • Hi Ali,

    I defer to Kel in regards to how best to set up your project. But regarding the below, from a generic tools point of view:

    Ali Mirzazadeh said:
    1. How did you do excluding from build? I made two directories in my project folder in the workspace, but the program seemed to be trying to build both even though I put the include to a specific director....I have a feeling it might be because the build settings automatically build everything in the main project folder regardless of included or not? How did you setup your directories to get it to correctly exclude from build?

    By default, CCS will assume all source files that are part of a project are to be built. But you can explicitly specify files/folder to exclude from the build. This exclusion applies to the current build configuration. That is the benefit of the build configuration I mentioned earlier. You can have multiple build configuration that exclude different files and have different preprocessor define values

    Thanks

    ki

  • Hi Ali,

    You can exclude files and folder at CCS Project, by right clicking and selecting "Exclude From Build". Here is my CCS project withe "SensorControllerLP" folder excluded from build.

    Then I set the SensorControllerCB folder at include options. After doing this rebuild-all.

    As far as I know this is the only option of having 2 different Sensor Controller Files/Project at CCS Project. You can not select either during runtime.

    -kel