NO:
W90P710 Programming Guide
VERSION:
2.0
PAGE:
178
The above information is the exclusive intellectual property of Winbond Electronics and shall not be disclosed, distributed or reproduced without permission
from Winbond.
Table No.: 2005-W90P710-11-A
14.3.2 GPIO
Output
Mode
Before the system use the GPIO pin as output pin, program need to configure the GPIO direction
register(GPIO_DIRn). The configuration sequence is described as follows.
1. Set
GPIO_CFGn
PTxCFGy
as GPIO purpose according to the adove method of Multiple
function setting
2. Set
the
GPIO_DIRn
OMDENx[y]
value as 1 (output mode).
3. Set
the
GPIO_DIRn
PUPENx[y]
value( internal pull-up enable or disable).
After the above steps, user can change the GPIO pin output value(high or low) by write 1 or 0 to
GPIO data output register(GPIO_DATAOUTn). Programmer should not change the value of whole
register except the corresponding field of the register.
A sample code set GPIO PORT0 pin1 as GPIO output, then change the output between high and
low is given below:
int GPIO_CFG=0;
// Set GPIO1 as I/O pin
GPIO_CFG=inpw(0xFFF83000);// Get GPIO_CFG0 value
GPIO_CFG=GPIO_CFG&0xFF3; // Set PT0CFG1, GPIO1 as I/O pin
outpw(xFFF83000,GPIO_CFG);// Write value to GPIO_CFG0
// Set GPIO1 as output mode, disable internal pull-up
GPIO_CFG=inpw(0xFFF83004);// Get GPIO_DIR0 value
GPIO_CFG=GPIO_CFG|(1<<17);// GPIO1 output mode
GPIO_CFG=GPIO_CFG&(0<<1) //disable pull-up
outpw(xFFF83004,GPIO_CFG);// Write value to GPIO_DIR0
// set GPIO1 output 1
GPIO_CFG=inpw(0xFFF83008);// Get GPIO_DATAOUT0 value
GPIO_CFG=GPIO_CFG|(1<<1);// GPIO1 output 1
outpw(xFFF83008,GPIO_CFG);// Write value to GPIO_DATAOUT0
// set GPIO1 output 0
GPIO_CFG=inpw(0xFFF83008);// Get GPIO_DATAOUT0 value
GPIO_CFG=GPIO_CFG&(0<<1);// GPIO1 output 0
outpw(xFFF83008,GPIO_CFG);// Write value to GPIO_DATAOUT0