m5223X

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

m5223X

1,138 Views
sk7499
Contributor I
I am trying to write and read from a gpio port on a m5223demo board can someone assist with  a example code for how to do this i have codewarrior 6.3v.  Im tring to figure out the board but there is little to no documentation avalable on how to program the board.
Labels (1)
0 Kudos
1 Reply

371 Views
SimonMarsden_de
Contributor II
Hi

The steps you need to take are:

(1) Initialise the appropriate Pin Assignment Register (PnPAR). Many of the pins on ColdFire are used for more than one function, so you need to specify that you want the GPIO usage.

(2) Initialise the appropriate Data Direction Register (DDRn) to specify whether you want the pin to be a GPIO Input or Output.

(3) For an output, specify the value you want to drive on the pin. There are several ways of doing this. One way is to write to the appropriate Port Output Data Register (Called PORTn on the 52235, although some other ColdFire families call it PODRn).

See the GPIO section of the manual for more details.

Here's some code for Freescale's M52235EVB evaluation board which flashes two LEDs connected to the timer port TC[3] and TC[2]:

/* Pin assignments for port TC
Pins are all GPIO outputs
*/
MCF_GPIO_DDRTC = MCF_GPIO_DDRTC_DDRTC3 |
MCF_GPIO_DDRTC_DDRTC2 |
MCF_GPIO_DDRTC_DDRTC1 |
MCF_GPIO_DDRTC_DDRTC0;
MCF_GPIO_PTCPAR = 0;



/* Loop to flash LEDs 2 (DTIN2) and 3 (DTIN3) alternately */
MCF_GPIO_PORTTC ^= MCF_GPIO_PORTTC_PORTTC3;
while (1) {
MCF_GPIO_PORTTC ^= MCF_GPIO_PORTTC_PORTTC3 |
MCF_GPIO_PORTTC_PORTTC2;
for (i = 0; i 2000000; i++)
asm (nop);
}

Hope this helps.


Simon
0 Kudos