Thanks I have tried this with a slight difference as there was no definition for sounder_monitoring_trigger.
Instead I was able to find:-
/* Trigger 1 - Sounder_Monitoring_Trigger */
#define ADC0_SOUNDER_MONITORING_TRIGGER 1U
Giving code like this.
uint32_t read_adc()
{
lpadc_conv_result_t config;
GPIO_PinWrite(GPIO, 1, Debug_1, 1);
LPADC_DoAutoCalibration(ADC0);
//LPADC_DoSoftwareTrigger(ADC0, 2); //trigger ADC read
LPADC_DoSoftwareTrigger(ADC0, ADC0_SOUNDER_MONITORING_TRIGGER); //trigger ADC read
GPIO_PinWrite(GPIO, 1, Debug_1, 0);
GPIO_PinWrite(GPIO, 0, Debug_4, 1);
while (!LPADC_GetConvResult(ADC0, &config, 0U)){}; //wait for result
GPIO_PinWrite(GPIO, 0, Debug_4, 0);
return (uint32_t) config.convValue; //return data
}
This now gets stuck in the while loop never gaining a result.
After looking at the user manual I believe the code I had originally with a value of 2U is correct, as the register is bitwise, so a 1U as now set up will trigger event 0, so now the wrong event.
The passed value is not shifted, it is used directly, as below.
/*!
* @brief Do software trigger to conversion command.
*
* @Param base LPADC peripheral base address.
* @Param triggerIdMask Mask value for software trigger indexes, which count from zero.
*/
static inline void LPADC_DoSoftwareTrigger(ADC_Type *base, uint32_t triggerIdMask)
{
/* Writes to ADCx_SWTRIG register are ignored while ADCx_CTRL[ADCEN] is clear. */
base->SWTRIG = triggerIdMask;
}
