Tool/software: Code Composer Studio
Hello.
There was an inexplicable problem for me with the Sensor Controller.
Briefly about the problem - Incorrect measurement results are periodically read.
Briefly about the program. The sensor controller reads the TDC from the pins. A modified example for taken as a basis in SCS - cap_touch_ulpsense (Capasitive Touch).
The main program initializes the RTC channel 1, for accurate samples of the 75ms interval. Initializes the RF core and sensor controller. In the main loop, the sensor controller program is launched, data that is read by the interrupt scTaskAlertCallback is expected. After this mainSemaphore is expected in the main cycle and after 75 ms everything repeats.
In this case, incorrect data is observed.
But if, before starting the sensor controller, insert any RF command (e.g. RF_cmdNop) and immediately send it to sleep RF_yield, then the sensor controller starts issuing the correct values at each start. I don’t understand this situation at all !!!
Because calling the RF core from sleep causes increased power consumption.
How can I make the sensor sensor work properly without calling RF _yield ???
/* * ======== empty.c ======== */ /* For usleep() */ #include <unistd.h> #include <stdint.h> #include <stddef.h> #include "scif.h" #include "xRf.h" #include <ti/sysbios/knl/Semaphore.h> #include <ti/sysbios/knl/Event.h> #include <ti/sysbios/BIOS.h> #include <xdc/runtime/Error.h> #include <ti/devices/DeviceFamily.h> #include DeviceFamily_constructPath(driverlib/interrupt.h) #include DeviceFamily_constructPath(driverlib/aon_rtc.h) #include DeviceFamily_constructPath(driverlib/aon_event.h) #include DeviceFamily_constructPath(driverlib/sys_ctrl.h) void RTC_IRQ_Config(void); void scInit(void); void scRunOnes(void); #define CLOCK_75MS 75 #define _1_MS_VALUE_ 0x40 uint32_t period_wakeup = (CLOCK_75MS * _1_MS_VALUE_); uint32_t rtc_now; // --- Semaphore --- Semaphore_Handle mainSemaphore; uint16_t rawdata[8]; Semaphore_Handle scSemaphore; // !!! if uncomment, data from SC normalize #define NORMAL_DATA_1 /* * ======== mainThread ======== */ void *mainThread(void *arg0) { // main semaphore for wakeup Semaphore_Params params; Semaphore_Params_init(¶ms); params.mode = Semaphore_Mode_BINARY; mainSemaphore = Semaphore_create(0, ¶ms, Error_IGNORE); // init CH1 RTC for my wakeup RTC_IRQ_Config(); //init RF RF_openRadio(); // Init Sensocontroller scInit(); //--- main loop --- while (1) { scRunOnes(); Semaphore_pend(mainSemaphore, BIOS_WAIT_FOREVER ); } //----------------- } void scTaskAlertCallback(void) { // Clear the ALERT interrupt source scifClearAlertIntSource(); //Access Sensor Controller task data structures here ... memcpy((void*)rawdata,(void*)scifTaskData.capacitiveTouch.output.raw, sizeof rawdata); // Acknowledge the ALERT event scifAckAlertEvents(); // data ready Semaphore_post(scSemaphore); } void scRunOnes(void) { #ifdef NORMAL_DATA_1 RF_runCmd(rfHandle, (RF_Op*)&RF_cmdNop, RF_PriorityNormal, 0, 0); RF_yield(rfHandle); #endif // Reset all data structures except configuration scifResetTaskStructs(1 << SCIF_CAPACITIVE_TOUCH_TASK_ID, (1 << SCIF_STRUCT_INPUT) | (1 << SCIF_STRUCT_OUTPUT)); // Start the "Capacitive Touch" Sensor Controller task scifExecuteTasksOnceNbl(1 << SCIF_CAPACITIVE_TOUCH_TASK_ID); // wait data... Semaphore_pend(scSemaphore,BIOS_WAIT_FOREVER); } void scInit(void) { // for SC Semaphore_Params params; Semaphore_Params_init(¶ms); params.mode = Semaphore_Mode_BINARY; scSemaphore = Semaphore_create(0, ¶ms, Error_IGNORE); scifOsalInit(); scifOsalRegisterTaskAlertCallback(scTaskAlertCallback); // Initialize the SCIF driver scifInit(&scifDriverSetup); } void CC_RtcReChargeCompareValue() { AONRTCCompareValueSet(AON_RTC_CH1, rtc_now + period_wakeup); SysCtrlAonSync(); } void RTC_IRQ_Handler(void) { rtc_now = AONRTCCompareValueGet(AON_RTC_CH1); CC_RtcReChargeCompareValue(); // recharge RTC compare value Semaphore_post(mainSemaphore); // wakeup main loop } void RTC_IRQ_Config(void) { AONRTCEventClear(AON_RTC_CH1); AONRTCChannelEnable(AON_RTC_CH1); AONRTCCombinedEventConfig(AON_RTC_CH0 | AON_RTC_CH1); AONEventMcuWakeUpSet(AON_EVENT_MCU_WU1, AON_EVENT_RTC_CH1); SysCtrlAonSync(); rtc_now = AONRTCCompareValueGet(AON_RTC_CH1); CC_RtcReChargeCompareValue(); }