Hi,
Forum just logged me out after typing this the first time - and trashed my message :-((. So here goes again…
I have EMX modules fitted to my own boards, and use V4.1 code.
I use AD0 and AD1 fed straight from an Op Amp with a VERY stable DC voltage (varies typically by 1/10 milliVolt during test period) measured with a bench DMM.
I still need to check for noise - and will decouple the AD pin with extra RC network tomorrow now - to be sure.
I read the A-D every second or so, and it varies by a considerable amount. The following is a capture of 20 readings (which I then average out) :
0x000000d5
0x000000d7
0x000000d7
0x000000d7
0x000000ce
0x000000ec
0x000000d6
0x000000d4
0x000000e8
0x000000dc
0x000000df
0x000000df
0x000000e1
0x000000d7
0x000000de
0x000000d8
0x000000d7
0x000000d9
0x000000d8
0x000000d8
This is unusable !!
Now - I am trying to understand how the AnalogIn pin code works - and I suspect that its running continually in BURST mode ???, and not just when I call ‘Read()’ ??
The reason I suspect this is that having added some direct Register access code - the readings vary between two consecutive Register reads !! :
private static Register PINSEL1 = new Register(0xE002C004);
private static Register AD0CR = new Register(0xE0034000);
private static Register AD0GDR = new Register(0xE0034004);
private static Register AD0STAT = new Register(0xE0034030);
private static Register AD0INTEN = new Register(0xE003400C);
private static Register AD0DR0 = new Register(0xE0034010);
private static Register AD0DR1 = new Register(0xE0034014);
Then in my method :
public static void Read()
{
uint r2 = 0;
uint r5 = AD0DR0.Read();
AVolts[cnt] = adA.Read();
r2 = AD0GDR.Read();
r5 = AD0DR0.Read();
r5 = AD0DR0.Read();
r2 = r2 & 0x40000000;
//if (r2 != 0)
// return;
//BVolts[cnt] = adB.Read();
r2 = AD0GDR.Read();
r2 = r2 & 0x40000000;
//if (r2 != 0)
// return;
if (++cnt > 19)
cnt = 0;
}
cnt is a simple counter so that I can average over 20 counts.
The readings are often accompanied by the ADC OVERRUN bit being set in DR0 and also GDR.
Setting breakpoints in this code - I can see that the two consecutive register reads (int r5) actually give different values.
Also the CPU User Manual states that the Overrun bit will be cleared on a register read - but its not being.
Hence my ‘guess’ that the A-D is being continually read at a high rate ???.
If this is so - then I guess I will just have to implement my own simple A-D read function using register accesses :-((.
Finally - is there a circuit diagram available for the EMX module please ??. I want to know how VDDA and VREF are being fed into the CPU
ie do they have adequate decoupling etc. ???
Been trying to get to the bottom of this instability for a while now - on and off :-((.
Was also waiting to see if it had been changed/fixed in 4.2…but it seems that is still not yet available :-((.
Many Thanks
Best regards
Graham