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.
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.R = 0x0200; // set PB0 as GPIO output
SIU.PCR.R = 0x0103; // set PB1 as GPIO input, pull ups enabled
// if PB pin is high then set PB high, else put it low
if(SIU.GPDI.R) SIU.GPDO.R = 0x1;
else SIU.GPDO.R = 0;
Retrieving data ...