Programming GPIO in MPC5668G

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

Programming GPIO in MPC5668G

ソリューションへジャンプ
1,812件の閲覧回数
ravikiranbhairu
Contributor II

Hello All,

 

i am new to using this MCU. How can i program a GPIO pin to act as an input and output? For ex to read value of led port and write the value into a led port?

Thank you in advance.

 

Regards,

Ravikiran    

ラベル(1)
タグ(2)
1 解決策
1,316件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Please refer to the following posted example; https://community.freescale.com/docs/DOC-329563.

It gives you basic demo code. It also set one pin to GPIO output and toggle it within timer interrupt.

To set the pin as input you need to set the SIU.PCR[x].IBE bit and read the pad level from the respective SIU.GPDI[x] register.

For example like this

SIU.PCR[16].R = 0x0200;                                // set PB0 as GPIO output

SIU.PCR[17].R = 0x0103;                                // set PB1 as GPIO input, pull ups enabled

// if PB[0] pin is high then set PB[1] high, else put it low

if(SIU.GPDI[16].R) SIU.GPDO[17].R = 0x1;            

else SIU.GPDO[17].R = 0;

BR, Petr

元の投稿で解決策を見る

1 返信
1,317件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Please refer to the following posted example; https://community.freescale.com/docs/DOC-329563.

It gives you basic demo code. It also set one pin to GPIO output and toggle it within timer interrupt.

To set the pin as input you need to set the SIU.PCR[x].IBE bit and read the pad level from the respective SIU.GPDI[x] register.

For example like this

SIU.PCR[16].R = 0x0200;                                // set PB0 as GPIO output

SIU.PCR[17].R = 0x0103;                                // set PB1 as GPIO input, pull ups enabled

// if PB[0] pin is high then set PB[1] high, else put it low

if(SIU.GPDI[16].R) SIU.GPDO[17].R = 0x1;            

else SIU.GPDO[17].R = 0;

BR, Petr