S32K146 PDB Example ERROR

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32K146 PDB Example ERROR

跳至解决方案
1,757 次查看
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

 

标记 (5)
0 项奖励
回复
1 解答
1,676 次查看
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 项奖励
回复
2 回复数
1,677 次查看
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 项奖励
回复
1,704 次查看
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 项奖励
回复