cancel
Showing results for 
Search instead for 
Did you mean: 

PORT A

danny23
Associate II
Posted on February 25, 2004 at 15:04

PORT A

2 REPLIES 2
danny23
Associate II
Posted on May 17, 2011 at 11:58

Can anyone please send or post a sample code on how to interface to PORT A as GP I/O?

How can i write a byte to port A and have it stay there untill i write something else?

How can i read from Port A?

Anything can help

Thank you
jdaniel
Associate II
Posted on May 17, 2011 at 11:58

DOTT,

Sure... try something like this (assuming you're writing in Keil C and have defined a variable called psd_regs at csiop):

psd_regs.CONTROL_A = 0x00; /* All pins set to GPIO mode */

psd_regs.DIRECTION_A = 0xFF; /* All pins set to outputs */

psd_regs.DRIVE_A = 0x00; /* All pins CMOS drive / low slew-rate */

psd_regs.OUTENABLE_A = 0xFF; /* All outputs enabled */

after that setup, you would be able to do something like

psd_regs.DATAOUT_B = 0x84;

and have the corresponding bits on the port set or cleared. If you want to switch them to inputs, you'd have to do something like:

psd_regs.DIRECTION_A = 0x00; /* All pins now inputs */

var = psd_regs.DATAIN_A;

Also, you can set each pin individually as an input or an output. It's a bit complicated, but it's explained pretty well in the datasheet.

Let me know if that works for you.

Best Regards,

Phaze426