Programming GPIO in MPC5668G

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

Programming GPIO in MPC5668G

Jump to solution
1,098 Views
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    

Labels (1)
Tags (2)
1 Solution
602 Views
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

View solution in original post

1 Reply
603 Views
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