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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

947件の閲覧回数
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++);
}

ラベル(1)
2 返答(返信)

854件の閲覧回数
danielmartynek
NXP TechSupport
NXP TechSupport

Hello, 

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

ATD0DIEN_IEN8 = 1;

Regards,

Daniel

854件の閲覧回数
harshal_pawar
Contributor III

Its working now !

Thanks for the help

0 件の賞賛