A-4
GPIO WDT BKL Programming MS-98F3
General Purposed IO
1. GeneralPurposedIO–GPIO/DIO
TheGPIOportconfigurationaddressesarelistedinthefollowingtable:
Name IOPort IOaddress Name IOPort IOaddress
N_GPI0 0xA03 Bit0 N_GPO0 0xA03 Bit4
N_GPI1 0xA03 Bit1 N_GPO1 0xA03 Bit5
N_GPI2 0xA03 Bit2 N_GPO2 0xA03 Bit6
N_GPI3 0xA03 Bit3 N_GPO3 0xA03 Bit7
1.1 SetoutputvalueofGPO
1. ReadthevaluefromGPOport.
2. SetthevalueofGPOaddress.
3. WritethevaluebacktoGPOport.
Example:SetN_GPO0output“high”
val=Inportb(0xA03); //Readvalu efromN_GPO0port.
val=val|(1<<4);//SetN_GPO0address(bit4)to1(output“high”).
Outportb (0x A03,val); //WritebacktoN_GPO0port.
Example:SetN_GPO1output“low”
val=Inportb(0xA03); //Readvalu efromN_GPO1port.
val=val&(~(1<<5));//SetN_GPO1address(bit5)to0(output“low”).
Outportb (0x A03,val); //WritebacktoN_GPO1port.
1.2 Read inputvaluefromGPI
1. ReadthevaluefromGPIport.
2. GetthevalueofGPIaddress.
Example:GetN_GPI2inputvalue.
val=Inportb(0xA03);//ReadvaluefromN_GPI2port.
val=val&(1<<2);//ReadN_GPI2address(bit2).
if(val) printf(“InputofN_GPI2isHigh”);
else printf(“InputofN_GPI2isLow”);