AnsweredAssumed Answered

Unclear behaviour of ADC_Enable/Disable

Question asked by Markus Krug on Jul 16, 2013
Latest reply on Jul 18, 2013 by Jiri Chvatik



I just discovered a behaviour of the PE ADC Component. I tried to use the ADC_Enable/Disable Methods. First I realized that the enable method did not turn on my ADC as expected. However if I set the marker on 'enable in init code' it starts working. So in a second stage I tried ADC_Disable and realized that it works as expected. However turning on the ADC right after disabling failed again. So I looked into the generated code. I was surprised because in disabling the code does something I would expect. It changes the configuration bits in the ADC to disable it:


LDD_TError Potentiometer_Disable(LDD_TDeviceData *DeviceDataPtr)


  ((Potentiometer_TDeviceDataPtr)DeviceDataPtr)->EnUser = FALSE; /* Set the flag "device disabled" */

  ADC_PDD_SetConversionTriggerType(ADC1_BASE_PTR, ADC_PDD_SW_TRIGGER); /* Select SW triggering */

  ADC_PDD_WriteStatusControl1Reg(ADC1_BASE_PTR, 0U, 0x1FU); /* Disable device */

  return ERR_OK;                       /* If yes then set the flag "device enabled" */



If you look in the enable code there is no access to the ADC configuration registers. It just changes a field in the LDD_TDeviceData. But that has no influence on the behaviour of the actual hardware.

LDD_TError Potentiometer_Enable(LDD_TDeviceData *DeviceDataPtr)


  ((Potentiometer_TDeviceDataPtr)DeviceDataPtr)->EnUser = TRUE; /* Set the flag "device enabled" */

  return ERR_OK;                       /* If yes then set the flag "device enabled" */



Does anyone understand the different behaviour of these functions?


Best Regards