Hello,
I am trying to use the internal ADC in my project. However, when I try to initialize the ADC, I get:
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.
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.
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.
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
Hi,
Did you enable the Module clock in PCC_ADCn?
Regards,
Daniel
Hello,
Thanks for the response.
Do you mean this?
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:
But PDB reports that it's disabled:
Hi,
Have you tried the adc_hw_trigger_s32k142 example that is available in S32 Design Studio?
Does it work?
After this code:
The clock is enabled in PCC registers, you can see it in the S32DS register view.
Regards,
Daniel