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,423件の閲覧回数
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,014件の閲覧回数
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,015件の閲覧回数
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