PDB adc trigger issue

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

PDB adc trigger issue

跳至解决方案
2,345 次查看
gnichimohamed
Contributor III

Hello

I am trying to trigger two adc channels from pdb on the K02.

Here us my code so far

SIM->SCGC6|=SIM_SCGC6_PDB(1);// enable clock for pdb
PDB0->SC|=PDB_SC_TRGSEL(0xF)     |//soft trigger
                      PDB_SC_PRESCALER(1) |
                      PDB_SC_MULT(0) |
                      PDB_SC_CONT_MASK |PDB_SC_PDBIE_MASK|
                      PDB_SC_PDBEN(1);

PDB0->CH[0].C1|=PDB_C1_BB(0x02) |PDB_C1_EN(0x03);
PDB0->MOD=2000;
PDB0->IDLY=2000;
PDB0->SC |= PDB_SC_LDOK_MASK;
SIM->SCGC6 |= SIM_SCGC6_ADC0_MASK; //enable clock for ADC0
ADC0->SC2 |=ADC_SC2_ADTRG_MASK;
ADC0->SC1[0]=ADC_SC1_ADCH(0x11);//ADC0CH11
ADC0->SC1[1]=ADC_SC1_ADCH(0x5);//ADC0CH5
ADC0->SC1[1]|=ADC_SC1_AIEN_MASK;
ADC0->CFG1 |=ADC_CFG1_MODE(0x03);

EnableIRQ(ADC0_IRQn);
NVIC_SetPriority(ADC0_IRQn, 0);
EnableIRQ(PDB0_IRQn);
NVIC_SetPriority(PDB0_IRQn, 1);
PDB0->SC |=PDB_SC_SWTRIG_MASK|PDB_SC_LDOK_MASK;

The problem is i can get the pdb interrupt to occur but the ADC interrupt seems to happen only ones at the start.
Thanks for the help.

标签 (1)
1 解答
1,848 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

When you set:
ADC0->SC1[0]=ADC_SC1_ADCH(0x01);
ADC0->SC1[1]=ADC_SC1_ADCH(0x01);  //using PTE16 as ADC0_DP1
PTE16 should be the singal input pin.

ADC0_Dx1.png

If you input the singal at PTE17, then AD channel 21 should be configured as below:
ADC0->SC1[0]=ADC_SC1_ADCH(0x15);
ADC0->SC1[1]=ADC_SC1_ADCH(0x15);  //using PTE17 as ADC0_DM1

ADC0_DM1.png

Even in 12bit mode there are big errors?

No. You can have a try after selected the correct input channel.

And I recommand this application note: AN5250 "How to Increase the Analog-to-Digital Converter Accuracy in an Application".

Best Regards,

Robin

在原帖中查看解决方案

6 回复数
1,848 次查看
gnichimohamed
Contributor III

So the issue is that i didn't activate the pre-triggers and the right delay so that the second pre-trigger will work.

PDB0->CH[0].C1|=PDB_C1_BB(0x02) |PDB_C1_TOS(0x03)|PDB_C1_EN(0x03);

Now there is two successive conversion on analog channel 5 and 11.

I wanted to check if the ADC is as accurate as it should be in this configuration so i used only channel 11 to be triggered two times in a row and look at the RA and RB results. When i use 16 bit conversion there is big differences between the two readings but in 12 bit mode the values are always exactly the same. I wonder if anyone has the same issue. Or have i done something wrong?

0 项奖励
回复
1,848 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Sorry for the late reply.
Yes you are right. The ADC module need time to achieve AD conversion. So you need set enough delay between two pre-trigger.
From the K02P64M100SFA DataSheet you can find below description:

16-bit accuracy specifications.png
So the analog channel 5 and 11(17) only meet the 13-bit differential/12-bit single-ended accuracy specifications.

And the analog channel 11 is not available for your chip. I think it's analog channel 17.

ADC0 Assignments.png

Best Regards,

Robin

1,848 次查看
gnichimohamed
Contributor III

Thank you Robin.

I set/

ADC0->SC1[0]=ADC_SC1_ADCH(0x01);
ADC0->SC1[1]=ADC_SC1_ADCH(0x01);  //using PTE17 as ADC0_DP1

Even in 12bit mode there are big errors? I start to question my ADC config or i can't use two the same ADC0_DP1 analog channel on both ADC conversion channels?

0 项奖励
回复
1,849 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

When you set:
ADC0->SC1[0]=ADC_SC1_ADCH(0x01);
ADC0->SC1[1]=ADC_SC1_ADCH(0x01);  //using PTE16 as ADC0_DP1
PTE16 should be the singal input pin.

ADC0_Dx1.png

If you input the singal at PTE17, then AD channel 21 should be configured as below:
ADC0->SC1[0]=ADC_SC1_ADCH(0x15);
ADC0->SC1[1]=ADC_SC1_ADCH(0x15);  //using PTE17 as ADC0_DM1

ADC0_DM1.png

Even in 12bit mode there are big errors?

No. You can have a try after selected the correct input channel.

And I recommand this application note: AN5250 "How to Increase the Analog-to-Digital Converter Accuracy in an Application".

Best Regards,

Robin

1,848 次查看
gnichimohamed
Contributor III

Thank you Robin. I was sure there was something wrong there, i was confused with the differential config. It seems that the ADC doesn't really have the precision of a 16bit ADC. I get now small errors in readings up to 20. 

I hope that recording audio in 16bit mode will be better than 12bit. 

0 项奖励
回复
1,848 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Gnichi,

Have you try to use these three ADC input pins: ADC0_DP0, ADC0_DM0, ADC0_DP3. Will all these pins get 20LSB error?

16 bit is the resolution of ADC, about the precision please read the "Table 24. 16-bit ADC characteristics" in DataSheet.

And be aware of "Reference-voltage noise" and "Analog-input signal noise" in AN5250.

Best Regards,

Robin

0 项奖励
回复