I want to use ADC

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

cross mob
Translation_Bot
Community Manager
Community Manager
Community Manager

I use MTB3.0
I built [CY8CPROTO-062-4343W]-[Dual-CPU_Empty_PSoC6_App] and [CY8CPROTO-062-4343W]-[ADC_base] project.
Of course both runs successfully.
I want to use ADC(single channel mode) in Empty project.
I copied adc_single_channel_init() , adc_single_channel_process() and declarations like "cyhal_adc_config_t adc_config = .... " from ADC_base project to Empty project.
But "adc_result_0 = cyhal_adc_read_nv... " in adc_single_channel_process() returns 0, so I CAN't use ADC in project other than ADC_base.
Please show me what I have to do to use ADC.
I'm sorry for poor English.

0 Likes
1 Solution
Translation_Bot
Community Manager
Community Manager
Community Manager

Thank you for your update.

Are using cm4 of the dual-core empty project for the ADC, and re-used the main.c code in ADC basic for the cm4?

In that case, please comment out the cm0plus deepsleep code in cm0plus 's main.c:

RyanZhao_0-1693912744264.png

If this CAN work, I think it is related with the interrupt settings for HAL. When cm0plus is in deep-sleep, the ADC interrupt doesn't work. I didn't check deeply on this, this could be one possible reason.

Best Regards,

Ryan

 

View solution in original post

0 Likes
5 Replies
Translation_Bot
Community Manager
Community Manager
Community Manager

Hi @kkonishi san,

Thank you for using our community.

To use code from the HAL, the specific driver header file CAN be included or the top level cyhal.h header CAN be include to allow access to any driver.

Please double-check if the above step is executed in your project.

RyanZhao_1-1692962475879.png

Best Regards, Ryan

0 Likes
lock attach
Attachments are accessible only for community members.
Translation_Bot
Community Manager
Community Manager
Community Manager

Thank you for answering.

I think I include correct headder files.

Here is my full source text.

 

 

0 Likes
Translation_Bot
Community Manager
Community Manager
Community Manager

Thank you for your update.

Are using cm4 of the dual-core empty project for the ADC, and re-used the main.c code in ADC basic for the cm4?

In that case, please comment out the cm0plus deepsleep code in cm0plus 's main.c:

RyanZhao_0-1693912744264.png

If this CAN work, I think it is related with the interrupt settings for HAL. When cm0plus is in deep-sleep, the ADC interrupt doesn't work. I didn't check deeply on this, this could be one possible reason.

Best Regards,

Ryan

 

0 Likes
Translation_Bot
Community Manager
Community Manager
Community Manager

It must be  one of reason.

But I failed debugging today, I don't know why.

I think modus toolbox is not easy.

I'll return after some practice.

Thank you very much.

 

0 Likes
Translation_Bot
Community Manager
Community Manager
Community Manager

Thank you for your update. Please feel free to contact us via Community if there are any further technical questions.

0 Likes