ADC Channel Change Locks into DevAssert Loop

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

ADC Channel Change Locks into DevAssert Loop

Jump to solution
1,378 Views
sparkee
Contributor V

The debugger unexpectedly stops at the following when I change ADC channel from 11U to any other channel (I've tried 5 or 6).  

I'm using the adc_hwtrigger_s32k144 example.  It was originally working at channel 12 out of the box and I made some changes to the ADC and moved to channel 11 and everything was working great.  I was printing the ADC output to the console correctly by changing the print() calls to printf().  When I changed from channel 11 to channel 10, I got the following screen:

pastedImage_1.png

Clicking resume doesn't move past it, I'm stuck in this for loop.  Never prints ADC to console.  I changed printf() back to print() but no luck.  Only thing that gets it working again is changing the channel back to 11.

I played with the ADC settings in processor expert but reverted back and no change.  Very strange.

UPDATE:

I attempted to start with a fresh version of the example to make sure I didn't cause the problem by messing with ADC parameters and got a similar result.

Labels (1)
1 Solution
1,342 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

seems it is stopping at below line in main.c 

DEV_ASSERT(adConv0_ChnConfig0.channel == ADC_CHN);

So do you have channel selected in ADC component same as ADC_CHN defined in main.c?

Did you generate PE code after changed done in PE?

BR, Petr

View solution in original post

2 Replies
1,343 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

seems it is stopping at below line in main.c 

DEV_ASSERT(adConv0_ChnConfig0.channel == ADC_CHN);

So do you have channel selected in ADC component same as ADC_CHN defined in main.c?

Did you generate PE code after changed done in PE?

BR, Petr

1,343 Views
sparkee
Contributor V

I started fresh with the example and generated PE code as soon as the example loaded.  The only change I made was to the line in main.c that defined the ADC_CHN.  I did not think I needed to generate code again.  I did make changes and generate code after the problem started happening though so I don't believe that is the issue.

#define ADC_CHN         12U

#####UPDATE######

I figured out the problem after thinking about what you said and figuring out what the DevAssert function was doing.  The PE has assigned a channel to the ADC and I'm changing it in the code but DevAssert() is checking that it's still the same as what PE assigned it.  Since I changed it, it hangs.

This leads to my question from a few days ago about the Blink LED example where I ask about redundancy of doing things in main.c that the PE has already done.  In that example, DevAssert() isn't being used so it doesn't matter but I think it's terrible practice to assign variables a value in multiple places.  Even if it doesn't cause compile problems, it makes it hard to debug later.  It's also very confusing to me to look through the examples and see things like that. It made me thing the PE wasn't doing what I thought it should be doing.  It would be better to put that code in as a comment that notes what you would do if PE hadn't already done the work for you.

Thank you PetrS

0 Kudos