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/CC1310: Communication between sensor controller and main controller

Part Number: CC1310

Tool/software: Code Composer Studio

Hello,

I am struggling with some handshaking communication between the main controller and the sensor controller. My application is using the sensor controller to count pulses from

an external device. My main controller wakes up and reads the count value from the sensor controller, but I also need the main controller to then set a clear flag

to the sensor controller. The sensor controller needs to clear its count value when it reads the flag. I started with the button debouncer sensor controller example.

Is there an example that shows handshaking between the sensor controller and main controller?  Is there a way to simulate input from the main controller in sensor controller studio?

Thanks,

Ken

  • Hi Ken,

    If you by "simulate input" means an synchronized handover then the answer is that there is no such API. The main CPU can of course write data into the Sensor Controller structures, there is just no "synchronous" API to do this.

    I would imagine that you can easily implement a very basic solution along the lines (on the sensor controller side):

    // Check for input
    if (inputWritten == true) {
    
    // Read input

    // Clear inputHandled flag }

    or

    while (inputWritten != true) {
       // Wait for input
    }
    
    // Read input
    
    // Clear inputHandled flag

    In other words, introduce 2 variable, "inputWritten" and "inputHandled" that you use in combinations on both sides to handshake the data handover.

  • Can you provide some clarification on the sensor controller's operation?

    1 I would like to have the sensor controller count pulses all the time using the interrupt, I used the button debouncer project. I would like to have this function running all the time. When I test the task this works fine.

    2. Every 10 minutes I would like to have the M4 come in and read and clear the count.

    3. in my previous code I used a timer to trigger a sensor controller execution event. So every time the timer hit the execution code would be executed.

    4. In my previous code, I started the sensor controller using the scifStartTasksNbl. Can the same call be used to start a sensor controller with an interrupt?

    Thanks,

  • Hi Ken,

    Have you considered using the "Pulse Counter" resource in the Sensor Controller to do this? It can run while the sensor controller is in standby so you do not need to keep it alive.

    This means you could for example do something along the lines of:

    Init Task:
    
    // Enable pulse counter with digital input pin as source
    pcntEnable(PCNT_INPUT_AUXIO_BASE + AUXIO_I_PULSE_CNT_INPUT);
    
    // Schedule next execution run, this assume the RTC is setup to 10 min interval
    fwScheduleTask(1);
    
    Execution task:
    
    // Read out count value. If the digital input pin could be unstable at this point, the input buffer must
    // be disabled before we call pcntGetValue()
    gpioDisableInputBuf(AUXIO_I_PULSE_CNT_INPUT);
    pcntGetValue(output.measuredPulseCount);
    gpioEnableInputBuf(AUXIO_I_PULSE_CNT_INPUT);
    
    // Restart counter 
    pcntDisable(); 
    pcntEnable(PCNT_INPUT_AUXIO_BASE + AUXIO_I_PULSE_CNT_INPUT);
    
    // Wake up the CM3 code
    fwGenAlertInterrupt() 
    
    // Schedule next execution run 
    fwScheduleTask(1);
    

    This (assuming the sensor controller RTC channel is configured to 10 minutes) would allow the Sensor Controller to run on a 10 minute interval on its own while keeping the pulse counter enabled. Every 10 min interval it would wake-up, store the value, restart counter and alert CM3. This means the CM3 do not really need to interact with the sensor controller in any other way than reacting to the interrupt and reading the stored value. Assuming the 10 minute interval you should not really risk any corruption of the value you are reading out.

    If you prefer the interrupt way I would say you are best(easiest solution is having the timer (for example a Clock object) on the CM3 side where you in the timer interrupt read out the current value and set a "Clear" flag that the sensor controller checks during the next interrupt to decide if to clear or increment. 

    As for 4) Not sure what you mean by this but you should be able to start a task from ISR context if you want but you could only have one task running at a time.