MC9S12XEP100 ADC problem

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

MC9S12XEP100 ADC problem

Jump to solution
1,984 Views
roberthiebert
Contributor IV

Hello all,
I am using a MC9S12XEP100CAL 112LQFP in a project and am having some issues with the analog to digital converter. I am using ADC0 and have it configured as follows:
- Enable PAD12 through PAD00
- Wrap after converting AN12
- No external trigger, 10 bit resolution, discharge cap before conversion
- Fast flag clear, continue in stop, no external trigger, sequence complete interrupt disabled, compare interrupt disabled
- Right justified data, 16 conversions, no Fifo, no freeze
- 24 cycle sample time, prescale = 2 for 8.3Mhz ATDCLK
At present I have 10K pots connected to all the inputs from the same 5 volt regulated supply. I have a dedicated ground return to all the pots. The conversions seem to work just fine except for one thing. When I turn the pots full travel one way I measure 5 volts to the pin and get an ADC reading of 1023 counts, which is what I would expect. However, when I turn the pots full travel the other way I measure 0 volts to the pin but get an ADC reading of between 32 and 33 counts, not the 0 counts that I would expect. All pots behave exactly the same way. There is no potential difference between the analog ground and the system ground. Does anyone have any suggestions as to what my problem might be?
Regards,
Robert

0 Kudos
1 Solution
1,820 Views
roberthiebert
Contributor IV
Spoiler
Hi Daniel,

I had considered the possibility of me enabling the pullups unintentionally last night, but it was getting late and my brain was ceasing to function so this morning I had another look at the listing file. Sure enough. I found some old code that I had forgotten to remove in my GPIO initialization macro that enabled all the pullups. I removed the code and re-assembled it. Voila, the ADC works as it should.

Thanks so much for your help.

Regards,

Robert

View solution in original post

12 Replies
1,972 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

as a first approach, in order to exclude electromechanical features of the potentiometer I would like to ask you to connect ADC input directly to  GND by some additional wire and/or connect it to vrl internally (Table 13-16. Analog Input Channel Select Coding) and measure it. Is there any change?

Of course, I would like to see register setup (not only description) and function where data is read.

Best regards,

Ladislav

 

0 Kudos
1,948 Views
lama
NXP TechSupport
NXP TechSupport

I do not understand clearly what you want to do from application point of view but:
1) you have set the fast flag clear and you also clear the flag SCF. Do not mix these two things!!!!. I discovered in past it makes problems.

movb #$60,ATD0CTL2 ; Load "ATD0CTL2" with %01100000 ; !!! you have fast flag clear.....,disabled interrupt <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;(no fast flag clear, continue in stop,
; no external trigger, Sequence
; complete interrupt disabled,
; Compare interrupt disabled)
; ^^^^^^^
; AFFC--+||||||
; ICLKSTP---+|||||
; ETRIGLE----+||||
; ETRIGP-----+|||
; ETRIGE------+||
; ASCIE-------+|
; ACMPIE--------+

movb #$80,ATD0CTL3 ; Load "ATD0CTL3" with %10000000 ; right justified result data ....I suggest to set FRZ1,0 to 0b10 .. better for debugging<<<<<<<<<<<<<<
;(right justifed data, 16 conversions,
; no Fifo, no freeze)
; ^^^^^^^^
; DJM-+|||||||
; S8C--+||||||
; S4C---+|||||
; S2C----+||||
; S1C-----+|||
; FIFO------+||
; FRZ-------++

...
...
movb #SCF,ATD0STAT0 ; Set the Sequence Complete Flag of ATD0STAT0 to clear the flag ; twice in the code

 

2) you use continous conversion. Does it mean you wait for SCF then reads result from the chanels which are also converted in parallel?
If you want to get result in some time it is better to perform single multi conversion started by writing to ATDCTL5
3) However, it looks like you start it once to continous conversion, wait and read the data,...then you only wait for SCF and then read the data.

 

Best regards,

Ladislav

0 Kudos
1,935 Views
roberthiebert
Contributor IV

Hi Ladislav,
Thanks again for your quick replies. Your point about enabling the conversion to finish before stopping in freeze mode is well taken. I will make that change.
What I am trying to accomplish is to have all ATD channels converted as fast as possible so I can sample them all together every time through the main loop. I don't know how much time it takes to do the conversion set, and when I first wrote the code I had no idea how much time it would take to complete one loop in my program. Since then, I have a counter at the end of my main loop and it looks like it runs at about 11,525 loops per second right now. I expect that number will drop as the processor gets more tasks, but I doubt that it would drop much lower than about 5000 loops per second or so. I really only need to sample all the ATD channels a maximum of about 85 times per second so I probably have lots of room to change things in the set up .
The way I have the code written now I call start "START_ATD0" macro, then convert the results to user units only once before I enter the main loop. This gives me the present state of all the sensors. Then I call the "RUN_ATD0" macro every time through the main loop to keep them all updated.
Given what I am trying to do, and the time frame in which I would like to do it, have you any suggestions for changes to my code that I could try?
Regards,
Robert

0 Kudos
1,923 Views
roberthiebert
Contributor IV

I gave things a bit of a rest to see if that might help with troubleshooting. As an experiment I disconnected all of my external pots so all that was connected to the ATD pins was the battery voltage sensing circuit on Ch0 and the output from the on board barometric pressure sensor on Ch7. When I did this the calculated battery voltage was still higher than it should be, as it was before, but the barometric pressure seemed to be correct. I don't know if it was before because I didn't do a calculation check then. Anyway, what I did notice was that all of the pins that had nothing connected to them all read either 1022 or 1023 counts. That doesn't seem right to me. It is almost as if there is a pull up somehow on all of the pins with the possible exception of Ch7. I went through all the things I could think of for the initialization process and modified my code. That didn't change anything. With the pots re-connected they all still read either 32 or 33 counts with no measurable voltage on the wires leading to the pins. The conversion sequence seems to operate normally. I've copied my initialization and application code below: Any opinions would be greatly appreciated.

Regards,

Robert

 

#macro INIT_ADC0, 0

;*****************************************************************************************
; - Initialize Analog to Digital Converter (ATD0) for continuous conversions
; 8.3MHz ATDCLK period = 0.00000012048 Sec.
; 10 bit ATD Conversion period = 41 ATDCLK cycles(ref page 1219)
; Sample time per channel = 24+2 for discharge capacitor = 26 ATDCLK cycles
; Sample time for 13 channels = (41+26)x13=871 ATDCLK periods = 0.000114810 Sec. (~115uS)
;*****************************************************************************************

movw #$1FFF,PT0AD0 ; Load Port AD0 Data Registers PT0AD0:PT1AD0
; with %0001111111111111 (General Purpose I/Os on pins 15,14,13
; ATD on pins 12,11,10,9,8,7,6,5,4,3,2,1,0)
;(Registers are %00000000 out of reset)

movw #$0000,DDR0AD0 ; Load Port AD0 Data Direction Registers DDR0AD0:DDR1AD0
; with %0000000000000000 (All pins inputs)
;(Registers are %00000000 out of reset)

movw #$0000,RDR0AD0 ; Load Port AD0 Reduced Drive Registers RDR0AD0:RDR1AD0
; with %0000000000000000 (Full Drive Strength Enabled)
;(Registers are 500000000 out of reset)

movw #$E000,PER0AD0 ; Load Port AD0 Pullup Enable Registers PER0AD0:PER1AD0
; with %1110000000000000 (Pullups enabled on pins 15,14,13
; Pullups disabled on pins 12,11,10,9,8,7,6,5,4,3,2,1,0)
;(Registers are %00000000 out of reset)

movb #$0C,ATD0CTL0 ; Load ATD0 Control Register 0 with %00001100
; (wrap after converting AN12)
; ^ ^
; WRAP-----+--+
;(Register is %00001111 out of reset)

movb #$30,ATD0CTL1 ; Load ATD Control Register 1 with %00110000
; (no external trigger, 10 bit resolution,
; discharge cap before conversion)
; ^^^^^ ^
;ETRIGSEL-+|||| |
; SRES--++|| |
; SMP_DIS----+| |
; ETRIGCH-----+--+
;(Register is %00001111 out of reset)


;* movb #$62,ATD0CTL2 ; Load ATD Control Register 2 with %01100010
;(fast flag clear, continue in stop,
; no external trigger, Sequence
; complete interrupt enabled,
; Compare interrupt disabled)
; ^^^^^^^
; AFFC--+||||||
; ICLKSTP---+|||||
; ETRIGLE----+||||
; ETRIGP-----+|||
; ETRIGE------+||
; ASCIE-------+|
; ACMPIE--------+
;(Register is %00000000 out of reset)

;* movb #$60,ATD0CTL2 ; Load ATD Control Register 2 with %01100000
;(fast flag clear, continue in stop,
; no external trigger, Sequence
; complete interrupt disabled,
; Compare interrupt disabled)
; ^^^^^^^
; AFFC--+||||||
; ICLKSTP---+|||||
; ETRIGLE----+||||
; ETRIGP-----+|||
; ETRIGE------+||
; ASCIE-------+|
; ACMPIE--------+
;(Register is %00000000 out of reset)

movb #$20,ATD0CTL2 ; Load ATD Control Register 2 with %00100000
;(no fast flag clear, continue in stop,
; no external trigger, Sequence
; complete interrupt disabled,
; Compare interrupt disabled)
; ^^^^^^^
; AFFC--+||||||
; ICLKSTP---+|||||
; ETRIGLE----+||||
; ETRIGP-----+|||
; ETRIGE------+||
; ASCIE-------+|
; ACMPIE--------+;
;(Register is %00000000 out of reset)

;* movb #$80,ATD0CTL3 ; Load ATD Control Register 3 with %10000000
;(right justifed data, 16 conversions,
; no Fifo, no freeze)
; ^^^^^^^^
; DJM-+|||||||
; S8C--+||||||
; S4C---+|||||
; S2C----+||||
; S1C-----+|||
; FIFO------+||
; FRZ-------++
;(Register is %00100000 out of reset)

movb #$82,ATD0CTL3 ; Load ATD Control Register 3 with %10000010
;(right justifed data, 16 conversions,
; no Fifo, Finish conversion before stop in freeze)
; ^^^^^^^^
; DJM-+|||||||
; S8C--+||||||
; S4C---+|||||
; S2C----+||||
; S1C-----+|||
; FIFO------+||
; FRZ-------++
;(Register is %00100000 out of reset)

movb #$E2,ATD0CTL4 ; Load ATD Control Register 4 with %11100010
;(24 cycle sample time, prescale = 2
; for 8.3MHz ATDCLK)
; ^ ^^ ^
; SMP-+-+| |
; PRS----+---+
;(Register is %00000101 out of reset)

movw #$1FFF,ATD0DIENH ; Load ATD0 Input Enable Register Hi byte and Lo byte with
; %000111111111111 (Disable input buffer pins 15,14,13
; Enable input buffer pins 12,11,10,9,8,7,6,5,4,3,2,1,0)
;(Register is %0000000000000000 out of reset)

;* movw #$E000,ATD0DIENH ; Load ATD0 Input Enable Register Hi byte and Lo byte with
; %1110000000000000 (Enable input buffer pins 15,14,13
; Disable input buffer pins 12,11,10,9,8,7,6,5,4,3,2,1,0)
;(Register is %0000000000000000 out of reset)

;* movw #$0000,ATD0DIENH ; Load ATD0 Input Enable Register Hi byte and Lo byte with
; %0000000000000000(Disable digital input buffers on all pins)
;(Register is %0000000000000000 out of reset)

#emac

#macro START_ATD0, 0

;*****************************************************************************************
;- Start ATD0 and get ADC values for all selected channels
;*****************************************************************************************

movb #$30,ATD0CTL5 ; Load ATD Control Register 5 with %00110000 (no special channel,continuous
; conversion, multi channel, initial channel 0)
; (Start conversion sequence)
; ^^^^^^^^
; SC-+||||||
; SCAN--+|||||
; MULT---+||||
; CD----+|||
; CC-----+||
; CB------+|
; CA-------+
;(Register is %00000000 out of reset)

brclr ATD0STAT0,SCF,* ; Loop here until Sequence Complete Flag is set

movb #SCF,ATD0STAT0 ; Set the Sequence Complete Flag of ATD Status Register 0 to clear the flag
ldd ATD0DR0H ; Load accumulator with value in ATD Ch00
std batAdc ; Copy to batAdc
ldd ATD0DR1H ; Load accumulator with value in ATD Ch01
std cltAdc ; Copy to cltAdc
ldd ATD0DR2H ; Load accumulator with value in ATD Ch02
std matAdc ; Copy to matAdc
ldd ATD0DR3H ; Load accumulator with value in ATD Ch03
std PAD03inAdc ; Copy to PAD03inAdc
ldd ATD0DR4H ; Load accumulator with value in ATD Ch04
std mapAdc ; Copy to mapAdc
ldd ATD0DR5H ; Load accumulator with value in ATD Ch05
std tpsADC ; Copy to tpsADC
ldd ATD0DR6H ; Load accumulator with value in ATD Ch06
std egoAdc1 ; Copy to egoAdc1
ldd ATD0DR7H ; Load accumulator with value in ATD Ch07
std baroAdc ; Copy to baroAdc
ldd ATD0DR8H ; Load accumulator with value in ATD Ch08
std eopAdc ; Copy to eopAdc
ldd ATD0DR9H ; Load accumulator with value in ATD Ch09
std efpAdc ; Copy to efpAdc
ldd ATD0DR10H ; Load accumulator with value in ATD Ch10
std itrmAdc ; Copy to itrmAdc
ldd ATD0DR11H ; Load accumulator with value in ATD Ch11
std ftrmAdc ; Copy to ftrmAdc
ldd ATD0DR12H ; Load accumulator with value in ATD Ch12
std egoAdc2 ; Copy to egoAdc2

#emac

#macro RUN_ATD0, 0

brclr ATD0STAT0,SCF,NoSeqCmplt ; If the Sequence Cpmplet Flag is not set, branch to
; NoSeqCmplt:

movb #SCF,ATD0STAT0 ; Set the Sequence Complete Flag of ATD0STAT0 to clear the flag
ldd ATD0DR0H ; Load accumulator with value in ATD Ch00
std batAdc ; Copy to batAdc
ldd ATD0DR1H ; Load accumulator with value in ATD Ch01
std cltAdc ; Copy to cltAdc
ldd ATD0DR2H ; Load accumulator with value in ATD Ch02
std matAdc ; Copy to matAdc
ldd ATD0DR3H ; Load accumulator with value in ATD Ch03
std PAD03inAdc ; Copy to PAD03inAdc
ldd ATD0DR4H ; Load accumulator with value in ATD Ch04
std mapAdc ; Copy to mapAdc
ldd ATD0DR5H ; Load accumulator with value in ATD Ch05
std tpsAdc ; Copy to tpsAdc
ldd ATD0DR6H ; Load accumulator with value in ATD Ch06
std egoAdc1 ; Copy to egoAdc1
ldd ATD0DR7H ; Load accumulator with value in ATD Ch07
std baroAdc ; Copy to baroAdc
ldd ATD0DR8H ; Load accumulator with value in ATD Ch08
std eopAdc ; Copy to eopAdc
ldd ATD0DR9H ; Load accumulator with value in ATD Ch09
std efpAdc ; Copy to efpAdc
ldd ATD0DR10H ; Load accumulator with value in ATD Ch10
std itrmAdc ; Copy to itrmAdc
ldd ATD0DR11H ; Load accumulator with value in ATD Ch11
std ftrmAdc ; Copy to ftrmAdc
ldd ATD0DR12H ; Load accumulator with value in ATD Ch12
std egoAdc2 ; Copy to egoAdc2

NoSeqCmplt:

#emac

0 Kudos
1,919 Views
roberthiebert
Contributor IV

I just did another check. With the external pots disconnected I checked the state of the ATD pins on the board connector. They all read between 4.97 and 5.01 volts so it looks like somehow those pins are being pulled up. So far I haven't found anything on the board that might do this.

Regards,

Robert

0 Kudos
1,881 Views
roberthiebert
Contributor IV

Hi all,

I'm still trying to figure this thing out. I really don't know if it is a hardware issue, or if I have something wrong in my initialization. As I mentioned before, with nothing connected to any of the analog pins, with the exceptions of Ch0 and Ch7, I am reading 5 or almost 5 volts to ground. Either the dedicated sensor return ground or system ground, same result. Can anyone tell me if this is normal or not?

Regards,

Robert

0 Kudos
1,849 Views
roberthiebert
Contributor IV

Still working on this issue. Everything points to the pullups being enabled. I did a test. I disconnected all the external pots from the ADC inputs and checked to see if I had current to ground. I did. Then I placed a 1k resistor in series with my Fluke 187 to ground. It read 118uA. Assuming there is a pullup to 5 volts this works out to 41.372K value for the pullup. I believe the internal pullups are supposed to be ~50K, so this indicates that my theory is probably correct.

I have PT0AD0 set to $1FFF (GPIO pins15...13, ATD pins 12...0)

I have DDR0AD0 set to $0000 (all pins inputs)

I have PER0AD0 set to $E000 (pullups enabled pins15...13, disabled pins 12...0)

Is it possible I have a bad chip? I have two assembled boards, both behave exactly the same, so both would have to be bad. Is this probable?

Robert

0 Kudos
1,827 Views
roberthiebert
Contributor IV

Hi Daniel,

Thanks so much for your reply and the attachment. Unfortunately I don't speak any of the higher languages and am programming in assembler. I have just made a bit of progress on this and will be doing some more tests today. When I get the results I will post them. Thanks again.

Regards,

Robert

0 Kudos
1,839 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Robert,

The measurement is interesting, it indeed seems like there are internal pull-ups enabled.

However, they are disabled by default.

danielmartynek_0-1609941880000.png

You don't even have to configure the PIM module to use the pins for ADC0.

So maybe you enabled them unintentionally.

 

You wrote:

I have PT0AD0 set to $1FFF (GPIO pins15...13, ATD pins 12...0).

PTxADx are Data registers, they can be read in GPIO Input mode and written in GPIO Output mode.

Please note that PT0AD0 is for AN8 - AN15 and PT1AD0 for AN0 - AN7, this can be confusing.

danielmartynek_1-1609942150203.png

Have you tried a simple test code like the attached one?

 

Thanks,

BR, Daniel

0 Kudos
1,821 Views
roberthiebert
Contributor IV
Spoiler
Hi Daniel,

I had considered the possibility of me enabling the pullups unintentionally last night, but it was getting late and my brain was ceasing to function so this morning I had another look at the listing file. Sure enough. I found some old code that I had forgotten to remove in my GPIO initialization macro that enabled all the pullups. I removed the code and re-assembled it. Voila, the ADC works as it should.

Thanks so much for your help.

Regards,

Robert
1,966 Views
roberthiebert
Contributor IV

Hi Ladislav,

Thanks so much for your quick reply.

My first thought was that it was a hardware issue as I have this setup working well on another board. I have two of these new boards fully populated and operating. Both behave the same way. I did your test and disconnected one of the ADC inputs. The result showed a count of 1023. When I connected the input wire to the system ground, it read 32 counts, same as before. I am using a two sided board, ground planes on both sides. With my Fluke 87 I checked the following pins to make sure they were all connected to the ground planes:

VSS1, pin 14

VSS2 Pin 66

VSSA1 pin 86

VSSX1 pin 106VSSX2 pin 106

VSSX2 pin 40

VSSX3 pin 44

Mode A/ PE5 pin 38

Mode B/PE6 pin 37

VRL pin 85

VSSPLL pin 45

Test pin 97

There was no difference in resistance between any of the pins and the ground plane.

Here is my initialization macro:

#macro INIT_ADC0, 0

;****************************************************************************************
; - Initialize Analog to Digital Converter (ATD0) PAD12 through PAD00 for continuous
; conversions
; 8.3MHz ATDCLK period = 0.00000012048 Sec.
; 10 bit ATD Conversion period = 41 ATDCLK cycles(ref page 1219)
; Sample time per channel = 24+2 for discharge capacitor = 26 ATDCLK cycles
; Sample time for all 16 channels = (41+26)x16=1072 ATDCLK periods = 0.00012915 Sec.
; (~129uS)
;*****************************************************************************************

movw #$E000,ATD0DIENH ; Load ATD0 Input Enable Register
; Hi byte and Lo byte with
; %1110000000000000 (PAD12 through PAD00 ADC)

movb #$0C,ATD0CTL0 ; Load "ATD0CTL0" with %00001100
; (wrap after converting AN12)
; ^ ^
; WRAP-----+--+

movb #$30,ATD0CTL1 ; Load "ATD0CTL1" with %00110000
; (no external trigger, 10 bit resolution,
; discharge cap before conversion)
; ^^^^^ ^
;ETRIGSEL-+|||| |
; SRES--++|| |
; SMP_DIS----+| |
; ETRIGCH-----+--+

;* movb #$62,ATD0CTL2 ; Load "ATD0CTL2" with %01100010
;(no fast flag clear, continue in stop,
; no external trigger, Sequence
; complete interrupt enabled,
; Compare interrupt disabled)
; ^^^^^^^
; AFFC--+||||||
; ICLKSTP---+|||||
; ETRIGLE----+||||
; ETRIGP-----+|||
; ETRIGE------+||
; ASCIE-------+|
; ACMPIE--------+

movb #$60,ATD0CTL2 ; Load "ATD0CTL2" with %01100000
;(no fast flag clear, continue in stop,
; no external trigger, Sequence
; complete interrupt disabled,
; Compare interrupt disabled)
; ^^^^^^^
; AFFC--+||||||
; ICLKSTP---+|||||
; ETRIGLE----+||||
; ETRIGP-----+|||
; ETRIGE------+||
; ASCIE-------+|
; ACMPIE--------+

movb #$80,ATD0CTL3 ; Load "ATD0CTL3" with %10000000
;(right justifed data, 16 conversions,
; no Fifo, no freeze)
; ^^^^^^^^
; DJM-+|||||||
; S8C--+||||||
; S4C---+|||||
; S2C----+||||
; S1C-----+|||
; FIFO------+||
; FRZ-------++

movb #$E2,ATD0CTL4 ; Load "ATD0CTL4" with %11100010
;(24 cycle sample time, prescale = 2
; for 8.3MHz ATDCLK)
; ^ ^^ ^
; SMP-+-+| |
; PRS----+---+

#emac

Here is my initial conversion macro:

#macro START_ATD0, 0

;*****************************************************************************************
;- Start ATD0 and get ADC values for all selected channels
;*****************************************************************************************

movb #$30,ATD0CTL5 ; Load "ATD0CTL5" with %00110000 (no special channel,continuous
; conversion, multi channel, initial channel 0)
; (Start conversion sequence)
; ^^^^^^^^
; SC-+||||||
; SCAN--+|||||
; MULT---+||||
; CD----+|||
; CC-----+||
; CB------+|
; CA-------+
brclr ATD0STAT0,SCF,* ; Loop here until Sequence Complete Flag is set

movb #SCF,ATD0STAT0 ; Set the Sequence Complete Flag of ATD0STAT0 to clear the flag
ldd ATD0DR0H ; Load accumulator with value in ATD Ch00
std batAdc ; Copy to batAdc
ldd ATD0DR1H ; Load accumulator with value in ATD Ch01
std cltAdc ; Copy to cltAdc
ldd ATD0DR2H ; Load accumulator with value in ATD Ch02
std matAdc ; Copy to matAdc
ldd ATD0DR3H ; Load accumulator with value in ATD Ch03
std PAD03inAdc ; Copy to PAD03inAdc
ldd ATD0DR4H ; Load accumulator with value in ATD Ch04
std mapAdc ; Copy to mapAdc
ldd ATD0DR5H ; Load accumulator with value in ATD Ch05
std tpsADC ; Copy to tpsADC
ldd ATD0DR6H ; Load accumulator with value in ATD Ch06
std egoAdc ; Copy to egoAdc
ldd ATD0DR7H ; Load accumulator with value in ATD Ch07
std baroAdc ; Copy to baroAdc
ldd ATD0DR8H ; Load accumulator with value in ATD Ch08
std eopAdc ; Copy to eopAdc
ldd ATD0DR9H ; Load accumulator with value in ATD Ch09
std efpAdc ; Copy to efpAdc
ldd ATD0DR10H ; Load accumulator with value in ATD Ch10
std itrmAdc ; Copy to itrmAdc
ldd ATD0DR11H ; Load accumulator with value in ATD Ch11
std ftrmAdc ; Copy to ftrmAdc
ldd ATD0DR12H ; Load accumulator with value in ATD Ch12
std PAD12inAdc ; Copy to PAD12inAdc

#emac

Here is the macro that does the conversion during the program execution:

#macro RUN_ATD0, 0

movb #SCF,ATD0STAT0 ; Set the Sequence Complete Flag of ATD0STAT0 to clear the flag
ldd ATD0DR0H ; Load accumulator with value in ATD Ch00
std batAdc ; Copy to batAdc
ldd ATD0DR1H ; Load accumulator with value in ATD Ch01
std cltAdc ; Copy to cltAdc
ldd ATD0DR2H ; Load accumulator with value in ATD Ch02
std matAdc ; Copy to matAdc
ldd ATD0DR3H ; Load accumulator with value in ATD Ch03
std PAD03inAdc ; Copy to PAD03inAdc
ldd ATD0DR4H ; Load accumulator with value in ATD Ch04
std mapAdc ; Copy to mapAdc
ldd ATD0DR5H ; Load accumulator with value in ATD Ch05
std tpsADC ; Copy to tpsADC
ldd ATD0DR6H ; Load accumulator with value in ATD Ch06
std egoAdc ; Copy to egoAdc
ldd ATD0DR7H ; Load accumulator with value in ATD Ch07
std baroAdc ; Copy to baroAdc
ldd ATD0DR8H ; Load accumulator with value in ATD Ch08
std eopAdc ; Copy to eopAdc
ldd ATD0DR9H ; Load accumulator with value in ATD Ch09
std efpAdc ; Copy to efpAdc
ldd ATD0DR10H ; Load accumulator with value in ATD Ch10
std itrmAdc ; Copy to itrmAdc
ldd ATD0DR11H ; Load accumulator with value in ATD Ch11
std ftrmAdc ; Copy to ftrmAdc
ldd ATD0DR12H ; Load accumulator with value in ATD Ch12
std PAD12inAdc ; Copy to PAD12inAdc

#emac

My apologies for the extreme commenting, but I am just a hobbyist and I have to keep reminding myself of what I am doing and how I am doing it.

Regards,

Robert

0 Kudos
1,956 Views
lama
NXP TechSupport
NXP TechSupport

Hmmm, 32 is high value I have never met with. It smells like the channel is influenced from other channels or dynamic parameters does not fit speed of measurement.

Could please:

1) Measure internal references

lama_0-1608022830008.png

2) decrease atd clock

3) increase sample period

4) make analysis for possible injection currents from other channels. (sett all other chanel so GND)

perform single measurement.

.... and now I am going to look at the code....

0 Kudos