┬ÁTasker Forum > FreescaleTM MC9S12NE64

Reading Analog to Digital Port



I'm trying to figure out how to read analogue on the PAD on the MC9S12NE64, can someone please point me in the right direction?



Hi Marco

Here is a very old file which was used once to trigger sending Emails when ADC inputs measured values lower or higher than defined levels.
I haven't use this in a long time but at least you will see how to configure and read the ADC inputs on the NE64.



Thanks Mark, that really put me on the right track.  I setup the port up so that it scans continiously, and set it to multi-channel Mode.

--- Code: ---    static int State = 0;

      ATDCTL3 = 0;       // Read all 8 Channels
      ATDCTL4 = 0xf3;    // 8 bit mode suitable for our bus speed
      ATDCTL2 = ADPU;    // power up the ADC
      ATDCTL5 = 0x30;       // Multi-Channel, Scan Mode
      State = 1;
--- End code ---

I just inserted this inside a looping function, and it only runs once.

Because the ADC scans continiously, I can just use ATDDR0H~ATDDR7H to aquire the ADC values.  I have tested all the ATD ports symoultaniously on the NeCore12Board, and it seems to work quite well.


[0] Message Index

Go to full version