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: Sharing ADC with Sensorcontroller

Other Parts Discussed in Thread: CC1310

Hello
I want to share the ADC Module with the Sensorcontroller/Maincontroller on an CC1310.
The Sensorcontrollertask is executed 3 times per second. In this task I'm logging the ADC value from DIO9 and DIO8.
In the Maincontroller i only want to read the Batteryvoltage on Pin DIO10.

Now the problem is, that the result from the ADC_convert() on the maincontroller is always ADC_STATUS_ERROR.
This only happens, when I acquire the Hardware semaphore AUX_SMPH_2 before the conversation.

Is it necessary to acquire the hardware semaphore on the main controller?
Whats the correct way tho share the ADC?

Thanks for the help!

Edit: formating

//
// MAIN CONTROLLER CODE
//
ADC_Handle   adc_h;
ADC_Params   adc_params;

void initAdc()
{
	ADC_init();
	ADC_Params_init(&adc_params);
}
int readAdc()
{
	AUXSMPHAcquire(AUX_SMPH_2); //get access to the adc (parallel used in Sensorcontroller!)

	adc_h = ADC_open(TRANS_V1_0_ADC2, &adc_params); //Battery ADC Channel
	result = ADC_convert(adc_h, &batteryvoltage);
	ADC_close(adc_h);
		
	AUXSMPHRelease(AUX_SMPH_2);
	
	if (result == ADC_STATUS_SUCCESS)
	{
		return batteryvoltage;
	}
	return 0;
}
//
// SENSORCONTROLLER CODE
//
fwAcquirePeripheral(PERIPHERAL_ADC);

adcEnableSync(ADC_REF_FIXED, ADC_SAMPLE_TIME_341_US, ADC_TRIGGER_MANUAL);       

adcSelectGpioInput(AUXIO_A_ADC_PIN_TEMPERATURE);                                        
adcGenManualTrigger();                                                          
adcReadFifo(output.adc);                                                   		

adcDisable();  

fwReleasePeripheral(PERIPHERAL_ADC);

//do some processing

fwScheduleTask(1); // Schedule the next execution

  • If you go into ADCCC26XX.c you will see that  ADCCC26XX_convert() do the following:

        if(!AUXSMPHTryAcquire(AUX_SMPH_2)){
            Power_releaseConstraint(PowerCC26XX_DISALLOW_STANDBY);
            if (object->isProtected) {
                SemaphoreP_post(&adcSemaphore);
            }
            return conversionResult;
        }

    When you do a AUXSMPHAcquire(AUX_SMPH_2); before calling this function, ADC_convert will no be able to get the semaphore and the conversion fails. Try to remove the acquire/ release in the CM3 since this is done in the driver.