gpio problem on mcf52259

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

gpio problem on mcf52259

Jump to solution
1,335 Views
robert_zhang
Contributor I

hi,all

i use gpio function on mcf52259 have following problem,i can read data throu porttc,but when i read data from porttc ,i cant read data from porttc,always is fffff.

do you know this problem?

Labels (1)
0 Kudos
1 Solution
415 Views
mjbcswitzerland
Specialist V

Hi

 

This is a common mistake. The PORTTC register is an output register and, when read, returns the value in the output register. Therefore its doesn't return the pin states.

 

To read the port inputs you need to read from the SETTC register.

 

The same is generally true for all ports, that is, write outputs using PORTXX and read inputs using SETXX.

 

To make this less cryptic I have renamed the SETXX registers to PORTIN_SETXX.

 

Regards

 

Mark

 

www.uTasker.com

 

 

View solution in original post

0 Kudos
1 Reply
416 Views
mjbcswitzerland
Specialist V

Hi

 

This is a common mistake. The PORTTC register is an output register and, when read, returns the value in the output register. Therefore its doesn't return the pin states.

 

To read the port inputs you need to read from the SETTC register.

 

The same is generally true for all ports, that is, write outputs using PORTXX and read inputs using SETXX.

 

To make this less cryptic I have renamed the SETXX registers to PORTIN_SETXX.

 

Regards

 

Mark

 

www.uTasker.com

 

 

0 Kudos