Here is a version of above using HAL.
Set up g_adc0 on ADC Diver on r_adc in the configurator:
- ICU:
- ADC0_SCAN_END = Priority 4
- ADC0_SCAN_END_B = Priority 4
- Module:
- Name = g_adc0
- Unit = 0
- Resolution = 12-Bit
- Alignment = Right
- Clear after read = ON
- Mode = Single Scan
- Channel Scan Mask :
- Channel 0 = Use in Normal/Group A
- Rest of channels = unused
- Rest of parameters all default
Code:
void process_divert_thread_entry(void)
{
ssp_err_t err;
adc_data_size_t testData;
err = g_adc0.p_api->open(g_adc0.p_ctrl, g_adc0.p_cfg); // confirmed SSP_SUCCESS
while (1)
{
err = g_adc0.p_api->scanStart(g_adc0.p_ctrl);
tx_thread_sleep (1); // let scan complete = more than enough time !!!
err = g_adc0.p_api->read(g_adc0.p_ctrl, ADC_REG_CHANNEL_0, &testData ); // NOTE 1.5 v measured on channel AN000
tx_thread_sleep (10);
}
// confirmed SSP_SUCCESS in all HAL steps above
// testData always reads 0
I do not understand why this does not work either ???
Thanks for your help,
Steve D