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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,418 次查看
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

标签 (1)
标记 (2)
1 解答
1,009 次查看
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

在原帖中查看解决方案

1 回复
1,010 次查看
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