 Hello everyone, Myself Prithviraj Thambe working as an assistant professor in Department of Electronics Engineering at Vulture Nation of Technology, Solapur. Welcome to this session. In this session, we are going to learn general purpose IO port of LPC176 set. At the end of this session, student will be able to illustrate the structure of GPIO related memory map registers. And they also configure desired functions of port pins of LPC176 set outline. Let us understand the ports of LPC176 set. So LPC176 set comes with five general purpose bi-directional digital IO ports, port 0 to port 4. They supports fast GPIO that is enhanced or accelerated features. Additionally, port 0 and port 2 pins can be used to generate a single interrupt. GPIO ports are generally used for general purpose input to output interfacing, driving indicators like LEDs, controlling off-grid devices like relays or sensing digital inputs. So let us see each port one by one, port 0, total 20 pins can be used as a GPIO. But you will see that P0.12, 13, 14 and 31 are reserved. They are not available for the user. For port 1, 24 pins are available and P1.2, 3, 5, 6, 7, 11, 12 and 13 are reserved. Port 2, total 14 pins are available, P2.14 through P2.31 are not available. For port 3, 2 pins are available only 3.25 and 3.26. Remaining pins are again reserved. Similarly for port 4, again 2 pins are available, 4.28 and 4.29 and the remaining pins are again reserved. Let us calculate the total number of GPIO pins available. So yes, total up to maximum 17 GPIO pins are available for the user. Now these ports can be controlled by 5 groups of memory map registers. They are byte addressable, half word addressable or word addressable. So fast IO direction control register, fast IO mask register, fast IO set register, fast IO clear register and fast IO pin value register. So these 5 registers you can use to use GPIO port functionality. So all these GPIO registers are as I said byte, half word and word addressable. So byte and half word addressable allows the user easier and faster access to the physical port pins. They are all bit level control registers means a single instruction controls any number of bits or pins in one port. So let us see general purpose IO port direction control register. So this word accessible fast IO DR register is a third bit wide controls the direction of each pin of port X. So here you will see that fast IO zero direction control register is rewriteable and the memory address is shown here. So total number of registers, direction control registers are 0, 1, 2, 3, 4. All the registers are rewriteable and the default values are 0, 0, 0. The meaning is all the GPIO port pins by default set to inputs after reset. So this fast IO direction control register controls the direction of each port pin of port X. Example fast IO zero direction control register bit zero controls P0.0 and bit 31 controls P0.31. So direction control bit is effective only when that particular pin GPIO function is selected. Again you have two values 0 and 1. So 0 means that pin will be configured as input and 1 means that pin will be configured as output. Now let us solve some examples how to set the directions. So let us use fast IO zero direction control register which selects the direction of port zero pins. So we need to follow some steps. So we need to first logical and the default contents of this register with a mask which is used to preserve the direction of other port pins which we are not interested and then logical are the result with a desired direction value. So let us set the direction of P0.4 which is a port zero pin as an input. So here you will see that the there are some predefined directions and we are interested in only P0.4 direction. So this predefined direction is the output and we need to change it to input. So first ended with this mask then or with the desired value we set the direction of P0.4 as a input. So after writing all these combinations in hex you will get these values. So we can write a statement like fast IO zero DR register ended with zero X F F F F F E F and odd with the desired value which is zero here. You can skip this step. Also keep in mind refer the standard header file LPC17XX.H for the standard definition of all these registers. Let us configure the P0.5 pin of port zero as the output. So here again we have a 32 bit pattern and we are interested in now bit five because bit five is responsible for setting the direction of P0.5. So here by default the direction of P0.5 set as input and we need to change it to the output. So first step is the ending ending with the mask and the mask is created like this. So zero value for bit five and one for the remaining bits. So after ending you will get that the direction of remaining pins are preserved only the direction of P0.5 is changed and we are ordering our desired value or desired direction for output which is one. So after ordering the desired value we will get final value. So after writing all these in hex we will see that FIO zero DR register ended with zero X F F F F F F DF which you can actually skip because by only ordering also you can change the direction of port pin as output. So FIO zero DR register odd with itself zero X zero zero zero zero two zero. So these statements change the direction of P0.5 as a output. You can skip this masking part and for writing your C program again refer a header file LPC 17 XX dot H for the standard definition of all these registers for further learning you can read LPC 16 set data sheet UM10360. Thank you.