In 9s12g128 chipset,how to select pad0 IO function?Since that PAD/AN0 is one pin.

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

In 9s12g128 chipset,how to select pad0 IO function?Since that PAD/AN0 is one pin.

668 Views
100asong
Contributor I

I don't know how to select PAD0 function and I don't know how to select AN0 function.Thanks.

Labels (1)
0 Kudos
Reply
1 Reply

511 Views
iggi
NXP Employee
NXP Employee

Hi,

The primary function of PAD/AN0 pin is GPIO. So if you do not use ATD's AN0 channel, then it can be used as GPIO.

There are 6 ATD control registers (ATDCTL0-5). The ATDCTL5 register's bits 0-3 (CD,CC,CB and CA) are used to select analog input channel. See MC9S12GRMV1, MC9S12G Family Reference Manual and Data Sheet and Table 11-14. ATDCTL5 Field Descriptions.

Note that analog function of the pin is active when ATD is active. After you configure the ADC by writing to ATD control register, the conversion starts with write to ATDCTL5 register, so this one should be configured last.

Moreover, an ATD input pin has General-Purpose Digital Port Operation.

Each ATD input pin can be switched between analog or digital input functionality.

The pad of the ATD input pin is always connected to the analog input channel of the analog mulitplexer.

Also, each pad input signal is buffered to the digital port register. This buffer can be turned on or off with the ATDDIEN register for each ATD input pin.

Below is a code snippet of ATD digital port operation:

###########################################

int my_variable @0x01000;

void main(void) {

DDR1AD_DDR1AD4=1;  //associated pin configured as input

PER1AD_PER1AD4=1;  //pull enable;

PPS1AD_PPS1AD4=1;  //pull down.

ATDDIEN_IEN4=1;//digital input enabled

PT1AD_PT1AD4=1;

EnableInterrupts;
my_variable = 10; 

   

  for(;;) {

_FEED_COP(); /* feeds the dog */

  } /* loop forever */

  /* please make sure that you never leave main */

}

###########################################