Microchip
直播中

吴觅

7年用户 199经验值
私信 关注
[问答]

ADCHS PIC32MZ EF硬件故障问题

大家好,我想和大家分享一下最近发生在我身上的这个问题。我已经设置了ADC7(共享的一个)来完成4个通道的扫描转换。所有的都工作得很好。BTW:这个ADC与EC芯片家族相比非常好!但是,我时常遇到ODD异常。即使在调试模式下,我也无法在我的代码中找到原因。而且故障点总是变化的,这使我发疯!发生了什么事?阅读PIC32 MZ EF电气特性数据表,我发现ADC可以接受从-Vref到+Vref变化的电压作为模拟输入。在我的例子中,Avdd和Vdd(除了一个小LC滤波器)一样,我正在用22K的电阻读取从接地连接到AVdd的LDR上的电压。对于Vref和+VREF,我已经编程AVDD和地面。所以,显然,我尊重规范。至少静态地说,我发现你不能太靠近AVDD(或+VREF),否则会发生非常奇怪的行为!因此,我已经修改了我的硬件,以限制模拟输入电压小于Avdd。在我的情况下,AVDD是3.3V,因此我有有限的模拟输入到3V max。这样的例外已经消失了!我希望与其他用户分享,以避免他们也会变成奇怪的现象疯狂!编辑:实验结果告诉我,如果你不转换任何模拟输入,那么例外不会发生!只有当转换模拟输入时,例外才会很快或更晚出现。这将有助于使你更加疯狂!-)

以上来自于百度翻译


      以下为原文

    Hi all, I want to share with you this problem that happened to me recently.

I have setup the ADC7 (the shared one) to do a scan conversion of 4 channels.
All was working perfectly. BTW: this ADC is very good compared to EC chip family!
However from time to time I have experienced ODD exceptions.
Even in Debug mode I wasn't able to find the cause in my code.
Moreover the point of failure changed always and this has made me crazy!
So what was happening?

Reading the PIC32 MZ EF data sheet on electrical characteristics I see that the ADC can accept as analog input a voltage that varies from -Vref to +Vref. In my case Avdd was the same as Vdd (apart a small LC filter) and I'm reading a voltage across an LDR connected from ground to AVdd with a 22K resistor. For -Vref and +Vref I have programmed AVdd and ground.
So, apparently I'm respecting the specifications. At least statically.

What I have discovered is that you CANNOT go too near AVdd (or +Vref) or very strange behaviors will happens!
Thus I have modified my hardware in order to limit the analog input voltages to less than Avdd. In my case the AVdd is 3.3v and thus I have limited analog inputs to 3v max.
This way the exceptions have been disappeared!

I wish to share this with other users in order to avoid that they will also become crazy about strange phenomena!

EDIT: Experimental results told me that if you do not convert any analog input then the exceptions doesn't happens! Only if you convert the analog input the exceptions will arise soon or later. This will contribute to make you even more crazy! :-)

回帖(3)

李天竹

2019-7-18 13:12:33
您不必说明什么是异常,但是从您的描述中可以看出,这可能是ADC处理代码中的某种错误,当从ADC are接收的值接近最大预期读数时,该错误将产生异常。

以上来自于百度翻译


      以下为原文

    You don't say what are the exceptions, but from your description it appears that this could be some sort of error in your ADC processing code which produces an exception when values received from ADC are close to max expected readings.
举报

李天竹

2019-7-18 13:29:06
很简单。ADC数据通过一些代码进行处理。如果数值高于某个数值,则出现溢出或逃逸并导致异常。当ADC不工作时,错误代码根本不执行,所以没有问题。

以上来自于百度翻译


      以下为原文

   


Very simple. The ADC data is processed by some code. If values are higher than a certain number, something overflows or runs away and causes exception(s). When ADC is not working, the faulty code doesn't execute at all, so there's no problem.
举报

云解相

2019-7-18 13:36:34
我排除这一点是因为采样值存储在32位变量内,因此不能用12位ADC值溢出。我选择获得无符号值(单极)。但是,我已经在这里发布了我的ADC代码:http://www..hip.com/for./m941056.aspxand,目前我正在使用:#definitionADC_MAX_SAMPLES_SHIFT 2All工作,几天后工作得很好……但是如果你在我的代码中发现任何问题,欢迎你告诉我代码是错误的!-)

以上来自于百度翻译


      以下为原文

    I exclude that because sampled values are stored inside 32 bit variables and thus cannot overflow with 12 bit ADC values. I have chosen to get unsigned values (uni-polar).
However i have already posted my ADC code here:
http://www.microchip.com/forums/m941056.aspx
and currently I'm working with:
#define ADC_MAX_SAMPLES_SHIFT 2
All is working perfectly by days... but if you will find any problem in my code you are welcome if you will demostrate me that the code is wrong! :-)
 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分