S9KEA ADC

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

S9KEA ADC

3,219 Views
caesar_song
Contributor III

Hi  Would you kindly heip

 Problem 1: After ADC initialization, ADC module does not work. Read register ADC_SC1 to observe that the ADCH value is 11111, which means that ADC module is disabled, and it is useless to write repeatedly.While other registers ADC_SC2 and ADC_SC3 are normal, why fail to write register ADC_SC1?

 

Question 2: Power pins VDD and VDDA/VREFH are directly connected together, and frequent power-on and power-off will cause the phenomenon of problem 1. Is it caused by this reason? 

 

 

问题1:ADC初始化后,ADC模块不工作,读寄存器ADC_SC1观察,其中的ADCH值是11111,也就是说ADC模块禁能,再重复写也没用。而其他寄存器ADC_SC2,ADC_SC3正常,为什么写寄存器ADC_SC1失败,

问题2:电源引脚VDD与VDDA/VREFH,直接连在一起使用,频繁上下电,是否会导致问题一的现象,是否是由于这个原因引起的?

Labels (1)
0 Kudos
Reply
9 Replies

3,003 Views
FuJu
Contributor I

您好,我已经按照您说的实行了。
还是没有解决问题,故障还是偶尔出现在刚上电的时刻。也就是说,上电时存在ADC模块启动不正常的现象,且通过ADC初始化,不能消除。
当发现ADC不能触发和转换时,ADC_SC1中的ADCH = 0x1F。
程序中ADC初始化时已经将ADC_SC4[AFDEP]写入 000,且每次触发通道转换时,先向ADC_SC1写入0x1F,再写入要触发的通道号。
在故障出现后,通过清除SIM_SCGC的第29位,关闭 ADC 时钟,然后再打开,重新设置ADC模块的相关寄存器。ADC模块仍不能回复正常工作。

什么原因能导致这个MCU 的ADC在上电时出现故障?且故障永远无法消除,必须通过重新上电或MCU复位,才有可能消除。
我们能进行电话沟通吗?
我的电话和微信是:13287679213,感激不尽。

Hi,
I've done what you said.
The fault still exists,
and the fault still occasionally appears at the moment of power on,and it cannot be eliminated through ADC initialization.
ADC_SC1 ADCH = 0x1F,when it is found that the ADC cannot trigger and convert. then ADC_SC1 can not be written, ADC_SC1 still keeps
0x1F.
ADC_SC4[AFDEP] has been written to 000 when the ADC is initialized in the program, and each time the channel conversion is triggered, 0x1F is written to ADC_SC1 first, and then the channel number to be triggered.
After a fault occurs, turning off the ADC clock by clearing bit 29 of SIM_SCGC, then turning it on again, by clearing bit 29 of SIM_SCGC, Rewrite the relevant registers of the ADC module, The fault always exists.

What causes the ADC of this MCU fail during power-on? And the fault can never be eliminated, except re-powered or MCU reset.

Can we talk on the phone ?My phone number is 13287679213,So is wechat. Very grateful!!!

0 Kudos
Reply

3,200 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

You have enable ADC gated clock by setting the bit 29 of SIM_SCGC register before you write ADC registers.

xiangjun_rong_0-1706235926505.png

Secondly, you have to connect a crystal on the XTAL/EXTAL pins, which is ADC clock.

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply

3,174 Views
caesar_song
Contributor III

Hi Pls help ,thanks

The ADC initialization has set bit 29 of the SIM_SCGC register, which also uses a 10M external crystal oscillator.

The following symptoms occasionally occur during power-on: The ADC does not work in single conversion mode and is read

Register observation, ADC_SC2, ADC_SC3 write value is normal,

The ADC_SC1 register cannot be written, resulting in the ADC cannot be triggered, where the ADCH value is 11111, and repeated writes cannot be written.Don't know why?

Register ADC_SC1 failed,

 

Is the power pin VDD used directly with VDDA/VREFH, or does the power-on slope affect the ADC?

 

 

ADC初始化已经设置寄存器SIM_SCGC的第29位,也使用了10M的外部晶振。
上电是时偶尔出现以下现象:单次转换模式下ADC不工作,读取
寄存器观察,ADC_SC2,ADC_SC3写入值正常,
而寄存器ADC_SC1无法写入,导致ADC不能触发,其中的ADCH值是11111,重复写也无法写入。不知道什么原因?
寄存器ADC_SC1失败,

电源引脚VDD与VDDA/VREFH,直接连在一起使用,或者上电斜率是否会影响ADC?

0 Kudos
Reply

3,144 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Okay, I see that you has set bit 29 of the SIM_SCGC register, which also uses a 10M external crystal oscillator. You have connected the VDD, VDDA/VREFH, it is okay.

I do not know if you use software triggering mode or hardware mode.

If you use software mode and use polling mode to check if the ADC sampling is complete, this is the code:

uint16_t sample[100];

uint16_t i;

void main()

{

i=0;

ADC_SC2=0x00; //use software triggering mode

 

while(1)

{

  //write the channel to ADC_SC1 register

ADC_SC1=0x01; //start-up ADC channel1 conversion

while(!(ADC_SC1&0x80)) {}

sample[i]=ADC_R;

if(i<100)

  {

    i++;

}

else

{

i=0;

__asm("nop"); //set a break point here

}

}

}

Pls have a try

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply

3,129 Views
caesar_song
Contributor III

Thanks for your strong support!!

 

您好,您还是没理解我提出的问题,
我已经能够正常使用ADC模块,多数情况下能够正常运行。
问题出现在刚上电的时刻,而且是偶尔出现。
当发现ADC不能触发和转换时,读出寄存器ADC_SC1,ADC_SC2,ADC_SC3观察,发现ADC_SC1中的ADCH = 0x1F,而寄存器ADC_SC2,ADC_SC3写入正确。
也就是说只有寄存器ADC_SC1写失败,触发通道没写入ADC_SC1。在故障出现后,多次写ADC_SC1,并读出ADC_SC1观察,发现ADC_SC1中的ADCH始终为11111。
我想知道的是,为什么刚上电时会出现这种现象,且只有重新上电才可以恢复。
 
我使用的是软件触发模式。ADC初始化代码如下:
 
 
 
you still don't understand my question,
I can use the ADC module aright,and it works aright in most cases.
But in the moment of MCU power on , the problem occurs occasionally.
When the fault occurs ,the ADC cannot be triggered and converted,  then read the registers ADC_SC1, ADC_SC2, ADC_SC3 and observe them,  ADCH = 0x1F in ADC_SC1, and the registers ADC_SC2, ADC_SC3 are written correctly.
In other words, only register ADC_SC1 failed to write, triggering channel can not be written to ADC_SC1. After the fault occurs, write ADC_SC1 for many times, read ADC_SC1, and observe that the ADCH in ADC_SC1 is always 11111.
then  it can only be restored when the power is turned on again, or the MCU be reset.
Now,What I want to know  why this fault occurs when the power is just turned on, 
 
this is the code:
//-------------------------------------------------------------------------------------------------------------------
//  @brief      ADC初始化
//  @Param      adcn_ch         选择ADC通道
//-------------------------------------------------------------------------------------------------------------------
void adc_init(ADCn_Ch adcn_ch)
{
    SIM->SCGC |= SIM_SCGC_ADC_MASK;         //开启ADC时钟
    
    ADC->APCTL1 |= 1<<adcn_ch;              //使能ADC引脚
}
 
void adc_start(ADCn_Ch adcn_ch)
{
 
    ADC->SC3 = (0
                | ADC_SC3_ADIV(3)           //分频系数8
                | ADC_SC3_MODE(0x01)         //分辨率10位
                | ADC_SC3_ADICLK(1)         //使用总线时钟2分频最为ADC得时钟源
                );
        
    ADC->SC2 = ADC_SC2_REFSEL(0);           //基准电压选择
 
    ADC->SC1 = ADC_SC1_ADCH(adcn_ch);       //启动转换 
}
 
void TaskAdc_Init(void)
{
adc_init(TIN_ADC);       //ADC通道初始化
adc_start(TIN_ADC);      //ADC转换开始
}
 
uint16 adc_get(void)
{
    uint16 result;
    if(!(ADC->SC1 & ADC_SC1_COCO_MASK)) return 0xFFFF; //未转换完成返回-1
    result = ADC->R;
    return (result & ADC_R_ADR_MASK);              //返回结果
    
}
 
//////////////
TaskAdc_Init();
uint16 temp ;
temp = adc_get();
if(0xFFFF!= temp) 
 {
 
else
{
 //set a break point here. Then the fault occurs: ADCH = 0x1F
}
0 Kudos
Reply

3,122 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Okay, I see your issue.

If you fail to write the ADC_SC1, pls write the ADC_SC1 with ADCH 11111 and set the ADC_SC4[AFDEP] 000 in binary.

Pls have a try

BR

XiangJun Rong

0 Kudos
Reply

3,082 Views
FuJu
Contributor I

硬件的模拟电压可上电时还没稳定好。会导致ADC模块不能使用吗?我的

If the voltage of the hardware is not stable when it is powered on, Will the power supply cause this fault?

0 Kudos
Reply

3,083 Views
FuJu
Contributor I

您好,我已经按照您说的实行了。
还是没有解决问题,故障还是偶尔出现在刚上电的时刻。也就是说,上电时存在ADC模块启动不正常的现象,且通过ADC初始化,不能消除。
当发现ADC不能触发和转换时,ADC_SC1中的ADCH = 0x1F。
程序中ADC初始化时已经将ADC_SC4[AFDEP]写入 000,且每次触发通道转换时,先向ADC_SC1写入0x1F,再写入要触发的通道号。
在故障出现后,通过清除SIM_SCGC的第29位,关闭 ADC 时钟,然后再打开,重新设置ADC模块的相关寄存器。ADC模块仍不能回复正常工作。

什么原因能导致这个MCU 的ADC在上电时出现故障?且故障永远无法消除,必须通过重新上电或MCU复位,才有可能消除。
我们能进行电话沟通吗?
我的电话和微信是:13287679213,感激不尽。

Hi,
I've done what you said.
The fault still exists,
and the fault still occasionally appears at the moment of power on,and it cannot be eliminated through ADC initialization.
ADC_SC1 ADCH = 0x1F,when it is found that the ADC cannot trigger and convert. then ADC_SC1 can not be written, ADC_SC1 still keeps
0x1F.
ADC_SC4[AFDEP] has been written to 000 when the ADC is initialized in the program, and each time the channel conversion is triggered, 0x1F is written to ADC_SC1 first, and then the channel number to be triggered.
After a fault occurs, turning off the ADC clock by clearing bit 29 of SIM_SCGC, then turning it on again, by clearing bit 29 of SIM_SCGC, Rewrite the relevant registers of the ADC module, The fault always exists.

What causes the ADC of this MCU fail during power-on? And the fault can never be eliminated, except re-powered or MCU reset.

Can we talk on the phone ?My phone number is 13287679213,So is wechat. Very grateful!!!

0 Kudos
Reply

3,043 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

我检查了 KEA family的勘误表, 它没有提及ADC这个问题,我也没有好的方法。

作为一个workaround,当这个问题发生时,你可以产生system reset.

xiangjun_rong_0-1707034891284.png

SCB-AIRCR|=0x04;

 

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply