What is required to read PAD8 and PAD9?

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

What is required to read PAD8 and PAD9?

873 Views
rzimmermann
Contributor I

I'm new to this processor family and need a bit of help understanding the pin setup.

I am using the DEVKIT-S12ZVC.  I want to do a simple read of a pin. 

I have the following code but fear there is more or I am doing something extra.

// Data Direction Register (Associated pin is configured as input)

DDRADH_DDRADH0 = 0;
DDRADH_DDRADH1 = 0;

// Digital Input Enable Register (Associated pin is configured as digital input)

DIENADH_DIENADH1 = 1;
DIENADH_DIENADH0 = 1;

// Port ADH Pull Device Enable Register (Pull device enabled)

PERADH_PERADH0 = 1;
PERADH_PERADH1 = 1;

//Port ADH Polarity Select Register (Pulldown device selected)
PPSADH_PPSADH0 = 1;
PPSADH_PPSADH1 = 1;

if(PTADH_PTADH1 != PTADH_PTADH0)
{
   asm nop;
}

I can understand setting the pull down since the DEVKIT has a capacitor on those lines. 

Setting the Digital Register is to enable the digital function and disable the analog function.

ADH and AHL are the only ports with the Digital Register. 

0 Kudos
Reply
1 Reply

766 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Roger,

I tested your code with Pullup on the AN9 (PAD9) and AN8 (PAD8) to detect short circuit on these pins and it works for me.

PPSADH_PPSADH0 = 0;
PPSADH_PPSADH1 = 0;

You can use PTADL to detect input state, but PTADL register is mainly used when the port is configured as an output. So, you may try reading the input state directly from Port Input Register (PTIADL). 

I hope it helps you.

Best regards,

Diana