Hi.
When the sensor Controller is using the ADC, and the Cortex-M3 wants to use it as well, how can the Cortex M3 check if the ADC is being used by the Sensor Controller?
BR
Anders Lange
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.
Hi.
When the sensor Controller is using the ADC, and the Cortex-M3 wants to use it as well, how can the Cortex M3 check if the ADC is being used by the Sensor Controller?
BR
Anders Lange
Hello Anders,
Good question. I have not tested this myself yet, but it should be possible.
There are two considerations:
1) PIN sharing and/or configuration.
The TI-RTOS driver use the TI-RTOS PIN driver. If both implementations use the same input pin for the ADC it can cause conflict unless care is taken as the TI-RTOS driver call to ADCCC26XX_open will reconfigure the selected pin.
2) ADC peripheral sharing through semaphore.
There is a designated hardware semaphore for the AUX ADC (AUX_SMPH_2 in AUX_SMPH). The TI-RTOS driver synchronize on this semaphore in ADCCC26XX_convert(), but you will need to do this manually before you open the TI-RTOS ADC driver if you use the same input pin (as mentioned above). You should also consider to control the sensor controller task (stop/start) in between for better control/overview. Please review the following two sensor controller example projects that show some of these elements:
Proposed solution:
Sensor Controller:
Enable the "Peripheral Sharing" in the sensor controller studio project and add:
fwAcquirePeripheral(PERIPHERAL_ADC); adcEnable() adcSelectGpioInput(); ... ADC Code ... adcDisable() fwReleasePeripheral(PERIPHERAL_ADC);
TI-RTOS:
Acquire the ADC semaphore bore you open the driver
AUXSMPHTryAcquire(AUX_SMPH_2);
ADCCC26XX_open
...ADC Code...
and if you use the same input pin, close the TI-RTOS ADC driver, reconfigure the pin for the sensor controller and release the semaphore:
// Close the TI-RTOS ADC Driver ADCCC26XX_close(); // Hand the ADC input IO pins back to the Sensor Controller scifReinitTaskIo(BV(SCIF_<ADC_TASK_NAME>_TASK_ID)); /* Release the ADC hw semaphore */ AUXSMPHRelease(AUX_SMPH_2);
Please refer to the implementation in ADCCC26XX_convert from the driver to see how the sempahore is used:
C:\TI\simplelink_cc2640r2_sdk_1_30_00_25\source\ti\drivers\adc\ADCCC26XX.c
Let me know how it works out, I am happy to follow up. I did not test this so there might be some corrections needed.