- · PORT0 has pins PORT0 has 0 to 031 pins
- · PORT1 has 16 to 031 pins.
- · PINSELx
- IODIRx
Direction bit for any pin must be set according to the pin functionality.
IODIRx=0x00000000;
- IOSETx
This register is used to produce a HIGH level output at the port pins configured as GPIO in an OUTPUT mode.
GPIO Port Output Set register.
This register controls the state of output pins in conjunction with the IOCLR register.
Writing ones produces highs at the corresponding port pins. Writing zeroes has no effect.
If any pin is configured as an input or a secondary function, writing 1 to the corresponding bit in the IOSET has no effect.
When any of the PORT pins used in OUTPUT mode and to make HIGH/Enable the particular PORT pins we use this IOSET register.
If we directed the PORT0 pins (0-3) as output mode / IODIR0=0x0000000F;
And now we want to enable/high the particular pins of that PORT0 we use the IOSETO register as follows
IOSET0=0x0000000F;/ we enable the pins (0-3) of PORT0
- IOCLRx
This register is used to produce a LOW level output at port pins configured as GPIO in an OUTPUT mode.
GPIO Port Output Clear register.
This register controls the state of output pins.
Writing ones produces lows at the corresponding port pins and clears the corresponding bits in the IOSET register.
Writing zeroes has no effect.
When any of the PORT pins used in OUTPUT mode and to make LOW/Disable the particular PORT pins we use this IOCLR register.
If we directed the PORT0 pins (0-3) as output mode / IODIR0=0x0000000F;
And now we want to Disable/Low the particular pins of that PORT0 we use the IOCLR register as follows
IOCLR0=0x0000000F;/ we Disable the pins (0-3) of PORT0
- IOPINx
GPIO Port Pin value register.
This register provides the value of port pins that are configured to perform only digital functions.
The register will give the logic value of the pin regardless of whether the pin is configured for input or output, or as GPIO or an alternate digital function.
The current state of the GPIO configured port pins can always be read from this register, regardless of pin direction.
As an example,
A particular port pin may have GPIO input, GPIO output, UART receive, and PWM output as selectable functions. Any configuration of that pin will allow its current logic state to be read from the IOPIN register.
Writing to the IOPIN register stores the value in the port output register, bypassing the need to use both the IOSET and IOCLR registers to obtain the entire written value.
This feature should be used carefully in an application since it affects the entire port.
The above statement will execute when the status of PORT1 and given data string equal to zero.
i.e. the status of PORT1 can be checked by using IOPINx Instruction






