ADC Behavior Coming out of VLPS (KL25)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC Behavior Coming out of VLPS (KL25)

843 Views
chuckh
Contributor III

I have been tracing down a bug where we loose communications on our USB BULK_OUT pipe (in from PC host) after several transitions in and out of VLPS and RUN modes.  I finally was able to catch it with a debugger and it seems that the code is getting stuck in a while loop waiting for the ADC COCO bit to be set. 

The code is as follows:

   volatile uint16_t dummyRead = ADC0_RA;

   ADC0_SC1A = ADC_SC1_ADCH(channel) ;     // start conversion

   while(!(ADC0_SC1A & ADC_SC1_COCO_MASK));

   dummyRead = ADC0_RA;

   return dummyRead;

I had looked at the ADC registers and saw nothing suspicious.

So, I looked at the KL25 Reference Manual and I found a subsection under ADC that states the ADC is reset upon exit from Low Power Stop.

So, I made a new build that reinitialized the ADC after coming out of VLPS, but before reenabling interrupts.

I ran with this code, but it seems like it is still hanging.  Has anyone had any similar problems before?


Thanks.

Labels (1)
0 Kudos
3 Replies

640 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Chuck,

It seems weird that the code still stuck in a while loop waiting for the ADC COCO bit to be set.

So I'd like to suggest that you can upload this code and I'll run this code with FRDMKL25Z, it's convenience to me figure out this issue.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

640 Views
chuckh
Contributor III

Well, it turns out that I may have resolved the ADC issue and it's getting messed up elsewhere.  Once I reinitialized this after low power and also ensured I wasn't running the ADC in an interrupt at the same time I was running in the main loop, I think that issue disappeared. 

It's not stuck in the ADC anymore, but I'm still having issues with the USB communications once the issue occurs.

I also cannot upload our code as it's proprietary and will also only run on our hardware, but thanks.

0 Kudos

640 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Chuck,

I‘ve learned that you may fix the issue when the project doesn't has other module operations except the module.

However it still occurs when work with USB communications and I'd like to suggest you could debug the code one step by one step to check out what the specific issue it is.

Hope this reply help and if you have any other questions, please feel free to contact with me.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos