S32K146 PDB Example ERROR

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

S32K146 PDB Example ERROR

Jump to solution
1,220 Views
f_gaudon
Contributor II

Hi, 

I need to understand few things with this example.

How do I get a 1.2ms period (see comment) with this configuration :

f_gaudon_0-1651754920848.png

 

I can read In the RM : Counting uses : (peripheral clock)/(MULT x PRESCALAR)

Here we got 80MHz / (40*128) = 15625 and PDB0->MOD = 14400 so I got a 1,085Hz freq .

Do I get something wrong with this ?

While debugging, I can see that I need more than 1.2ms ton reenter in my interruption but if I comment the line ADC_result = ADC0->R[0]; I reenter in my interruption without delay. Do the reading clear any flag ?

 

ISR code : 

f_gaudon_1-1651754963317.png

 

Thanks for your answers,

Florian

 

0 Kudos
Reply
1 Solution
1,139 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

your calculation is correct and you confirmed it by measurement you did.
Unfortunately example description here is wrong.
You need to read ADC result register to clear COCO flag. An interrupt is generated if the respective SC1n[AIEN] and SC1n[COCO] are set.

BR, Petr

View solution in original post

0 Kudos
Reply
2 Replies
1,140 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

your calculation is correct and you confirmed it by measurement you did.
Unfortunately example description here is wrong.
You need to read ADC result register to clear COCO flag. An interrupt is generated if the respective SC1n[AIEN] and SC1n[COCO] are set.

BR, Petr

0 Kudos
Reply
1,167 Views
f_gaudon
Contributor II

I just put this piece of code in the ADC ISR : 

PTB-> PTOR |= 1 << 17; // Toggle

And this is what I see with my scope : 

SDS00001.png

I have the 1,09 Hz freq I calculated ...

When I open the project in SDK example it says : 

f_gaudon_0-1652189332055.png

 

Period = 9ms 

Then in the code comment : 

f_gaudon_1-1652189365945.png

 

But I can see on my scope 0,91s period.

Which one of those periods is the correct one ? 

Thanks

0 Kudos
Reply