How to output 8-bit or 16-bit data to Port AD?

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

How to output 8-bit or 16-bit data to Port AD?

Jump to solution
871 Views
aaronlee
Contributor V

Hi,

I can out 1-bit data to PAD0 as follow:

GPIO_CONFIG(ADL,0,OUTPUT); // Configure PAD0 as OUTPUT

GPIO_WRITE_VALUE(ADL,0,1); // PAD0: HI

How to output 8-bit data to PAD0~7?

How to output 16-bit data to PAD0~15?

Best Regards,

Aaron

Labels (1)
Tags (2)
1 Solution
462 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

 

You can set it as follows:

unsigned char data8 = 0xff;

unsigned int data16 = 0xbbbb;

 

// Set port as output

DDRADH = FF;   // output

DDRADL  = FF;   // output

 

// Write to AD Port Data Register

// 8-bit write

PTADL = data8;

 

// 16-bit write

PTADL = (data16 & 0xFF);

PTADH = (data16 >> 8);

 

You can also set the port as output after setting Port Data Registers PTADL/H, this registers hold the data while the port is set as input (DDRADH/L == 0x0000).

 

Regards,

Daniel

View solution in original post

1 Reply
463 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

 

You can set it as follows:

unsigned char data8 = 0xff;

unsigned int data16 = 0xbbbb;

 

// Set port as output

DDRADH = FF;   // output

DDRADL  = FF;   // output

 

// Write to AD Port Data Register

// 8-bit write

PTADL = data8;

 

// 16-bit write

PTADL = (data16 & 0xFF);

PTADH = (data16 >> 8);

 

You can also set the port as output after setting Port Data Registers PTADL/H, this registers hold the data while the port is set as input (DDRADH/L == 0x0000).

 

Regards,

Daniel