Unable to access ADC registers

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to access ADC registers

506 Views
sripav-7
Contributor III

Hello,

I am trying to use the internal ADC in my project. However, when I try to initialize the ADC, I get:

pastedImage_1.png

I cannot access any of the ADC registers and the same error persists. My ADC functional clock is set to SIRCDIV2_CLK (8 MHz), PDB block set to bus clock and turned on, Extension ADC clock divide set to 2. SOSC and SPLL are disabled. Frequency in run mode is 48 MHz.

Any leads regarding this issue are appreciated.

Thank you.

Labels (1)
Tags (1)
0 Kudos
6 Replies

224 Views
sunilkumarc
Contributor I

PCC->PCCn[PCC_ADC0_INDEX] |= PCC_PCCn_PCS(1); /* PCS=1: Select FIRC */

PCS(1) - SOSCDIV1

PCS(2) - SIRCDIV1

PCS(3) - FIRCDIV1

PCS(6) - SPLLDIV1

So, I suppose in order to enable FIRC clock for ADC.

PCS(3) needs to be enabled.

so,

PCC->PCCn[PCC_ADC0_INDEX] |= PCC_PCCn_PCS(3); /* PCS=3: Select FIRC */

Please check the same and let me know.

0 Kudos

224 Views
sripav-7
Contributor III

Hi,

I tried that example and it works as expected. I am using a custom board that doesn't have SOSC, but PCC and PDB are enabled in that code and ADC is initialized properly. I can't seem to find what the problem with my other code is. 

0 Kudos

224 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Can you share the code so that I can test it?

If you don't want to share the code here, you can create a ticket.

https://community.nxp.com/docs/DOC-329745 

Thanks,

Daniel

0 Kudos

224 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Did you enable the Module clock in PCC_ADCn?

pastedImage_1.png

Regards,

Daniel

0 Kudos

224 Views
sripav-7
Contributor III

Hello,

Thanks for the response.

Do you mean this?

pastedImage_1.png

If not, I cannot find anything about PCC in processor expert. I put these line before ADC initialization to enable PCC manually and it still has the same problem:

PCC->PCCn[PCC_ADC0_INDEX] &= ~PCC_PCCn_CGC_MASK; /* Disable clock to change PCS */
PCC->PCCn[PCC_ADC0_INDEX] |= PCC_PCCn_PCS(1); /* PCS=1: Select FIRC */
PCC->PCCn[PCC_ADC0_INDEX] |= PCC_PCCn_CGC_MASK; /* Enable bus clock in ADC */

When I read registers, PCC reports that it is enabled:

pastedImage_1.png

But PDB reports that it's disabled:

pastedImage_2.png

0 Kudos

224 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Have you tried the adc_hw_trigger_s32k142 example that is available in S32 Design Studio?

Does it work?

pastedImage_1.png

After this code:

pastedImage_2.png

The clock is enabled in PCC registers, you can see it in the S32DS register view.

pastedImage_3.png

Regards,

Daniel

0 Kudos