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.

SIMPLELINK-CC2640R2-SDK: v3.30: Set Sensor Controller scifStartRtcTicksNow()?

Part Number: SIMPLELINK-CC2640R2-SDK


Hi,

At Simplelink Academy Sensor Controller here is the code set the Task Execution every 1 second. I have tested this and works. But I do not understand why you need to divide it by 1. Its like 65536 / 1 = 65536. So what is the explanation why you need to divide it by 1.

// Set the Sensor Controller task tick interval to 1 second
uint32_t rtc_Hz = 1;  // 1Hz RTC
scifStartRtcTicksNow(0x00010000 / rtc_Hz);

-kel

  • Hi Markel,

    You are correct, in this particular case dividing by 1 does not make a difference to the end result and it may seem redundant.

    It is, however, recommended in the lab to play around with the RTC interval by changing rtc_Hz variable which makes it important to have line 3 in your attached code as-is. 

    Thanks, 
    Elin

  • Okay, I still do not get it. Nevermind, I will figure it out. Lets say you set the rtc_Hz to 2. 65536 / 2 is 32768, = 0.5 seconds task interval. I mean how do you explain that to other people. Anyway, if someone ask me, I will just say to ask at TI E2E Forum.

    -kel

  • Also, I want to inform you that the input.adcValue is wrong. It should be output.adcValue.

    adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_2P7_US, ADC_TRIGGER_MANUAL);
    
    // Sample the analog sensor
    adcGenManualTrigger();
    adcReadFifo(output.adcValue);
    
    // Disable the ADC
    adcDisable();
    
    U16 oldState = state.high;
    if (input.adcValue > cfg.threshold) {
        state.high = 1; // High input - > High state
        gpioClearOutput(AUXIO_O_GREEN_LED);
    } else {
        state.high = 0; // Low input -> Low state
        gpioSetOutput(AUXIO_O_GREEN_LED);
    }
    
    if (oldState != state.high) {
        // Signal the application processor.
        fwGenAlertInterrupt();
    }
    
    // Schedule the next execution
    fwScheduleTask(1);