2004-02-25 06:04 AM
2011-05-17 02:58 AM
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 you2011-05-17 02:58 AM
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