MCF52233DEMO Inputs

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

MCF52233DEMO Inputs

1,635 Views
w2vy
Contributor V
This is so silly it is nuts.

I want to use the GPT0 as an input (which is the Default) and I can't seem to get it working.

Here is some code that *should* echo the state of GPT0-3 on  TIN0-3 (w/LEDs on the DEMO board)

Code:
#include <stdio.h>#include "common.h"#include "m52233DEMO.h"int main() {    MCF_GPIO_DDRTA = 0; // Inputs    MCF_GPIO_PTAPAR = 0; // GPIO Pins    MCF_GPIO_PTCPAR = 0; // GPIO Pins    MCF_GPIO_DDRTC = 0x0F; // Outputs    MCF_GPIO_PORTTC = 0; // Turn LEDs off    while (1) {        uint8 ta, tc;        ta = MCF_GPIO_PORTTA;        tc = 0;        if (ta&1) tc |= 1;        if (ta&2) tc |= 2;        if (ta&4) tc |= 4;        if (ta&8) tc |= 8;        MCF_GPIO_PORTTC = tc;    }}

 

Labels (1)
0 Kudos
2 Replies

264 Views
mjbcswitzerland
Specialist V
Hi w2vy

To read the port input state use the SETTA register rather than the PORTTA register.
Reading PORTTA returns the current state of the register and not the current pin state.

Regards

Mark Butcher

www.uTasker.com

0 Kudos

264 Views
w2vy
Contributor V
That was it... Thanks
(I knew it was stupid!)
0 Kudos