Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 6 Forum Discussions

Gintaras
Level 2
Level 2
10 replies posted 25 sign-ins 10 sign-ins

Hi,

I had to enable the continuous scanning myself in HAL library to get the ADC running continuously.

I have modified the library mtb_shared\mtb-hal-cat1\latest-v1.X\COMPONENT_CM4\source\cyhal_adc.c

in function cy_rslt_t cyhal_adc_configure(cyhal_adc_t *obj, const cyhal_adc_config_t *config)

Line 1103:

if(config->continuous_scanning)
{
obj->continuous_scanning = true;
obj->conversion_complete = false;
Cy_SAR_StartConvert(obj->base, CY_SAR_START_CONVERT_CONTINUOUS);
}

Before it was like  shown below:

Line 1103:

if(obj->continuous_scanning)
{
obj->conversion_complete = false;
Cy_SAR_StartConvert(obj->base, CY_SAR_START_CONVERT_CONTINUOUS);
}

 

BR,

Gintaras

0 Likes
1 Solution
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,

This issue is resolved in the latest PDL.

Best Regards,
Vasanth

View solution in original post

0 Likes
4 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Gintaras,

Thanks for reporting the issue. Let's check this at our side and get back to you.

Best Regards,
Vasanth 

0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Gintaras,

Could you confirm whether the following  code snippet works at your end?


This snippet shows how to run the ADC in continuous mode and process results as each scan completes.

 
static cyhal_adc_channel_t adc_channels[NUM_CHANNELS];
 
static void adc_continuous_event_handler(void* arg, cyhal_adc_event_t event)
{
CY_UNUSED_PARAMETER(arg);
CY_UNUSED_PARAMETER(event);
/* Note: arg is configured below to be a pointer to the adc object */
if(0u != (event & CYHAL_ADC_EOS))
{
for(int i = 0; i < NUM_CHANNELS; ++i)
{
/* Perform application-specific processing of the ADC result */
process_adc_result(i, cyhal_adc_read(&adc_channels[i]));
}
}
}
 
void snippet_cyhal_adc_continuous_read(void)
{
cyhal_adc_t adc_obj;
/* Initialize the each member of the adc_channels array as shown in Snippet 2 */
cyhal_adc_config_t config = { /* Other configuration options are omitted here for clarity */ .continuous_scanning = true };
 
/* Register a callback and set the callback argument to be a pointer to the adc object
* so that we can easily reference it in the event handler. */
cyhal_adc_register_callback(&adc_obj, &adc_continuous_event_handler, &adc_obj);
 
/* Subscribe to the end of scan event so that we we can process the results as each scan completes*/
 
/* Call the ADC configure function to begin continuous scanning */
cyhal_adc_configure(&adc_obj, &config);
}
 
Best Regards,
Vasanth
0 Likes
Gintaras
Level 2
Level 2
10 replies posted 25 sign-ins 10 sign-ins

Hi,

The event handler is never called using this method.

Regards,

Gintaras

0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,

This issue is resolved in the latest PDL.

Best Regards,
Vasanth

0 Likes