How to use Port AD0 of MC9S12XEP100 as general purpose input?

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

How to use Port AD0 of MC9S12XEP100 as general purpose input?

918 Views
harshal_pawar
Contributor III

I have developed a code below for glowing LED (on port PH2) whenever switch is pressed (on PAD08). But it doesn't working.

Attached is the Schematic of the same.

Code:

#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include <MC9S12XEP100.h>
#include <stdlib.h>


void delay();

void main(void)
{

PTH_PTH2= 0;  
DDRH_DDRH2=1;       /* PH2-LD2 as Output */

DDR0AD0_DDR0AD00=0;        /* PAD08 as Input */

while(1)
{

if(PT0AD0_PT0AD00!=0b1)       /* Check switch on PAD08 */
{
PTH_PTH2= 1;       /* LED ON */
delay();
}
else
{
PTH_PTH2= 0;       /* LED OFF */
delay();
}

}

void delay()
{
unsigned int i,j;

for(i=0;i<10000;i++);
for(j=0;j<10000;j++);
}

Labels (1)
2 Replies

825 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello, 

You need to enable the ATD Digital input buffer of the pin.

ATD0DIEN_IEN8 = 1;

Regards,

Daniel

825 Views
harshal_pawar
Contributor III

Its working now !

Thanks for the help

0 Kudos