
This is used to store user-defined bit-sized variables. The 8051 microcontrollers have BDATA area which is around 16-bytes in size. this feature is exclusively available when you are working with Keil software. The ^ symbol that is used to specify the 5 th pin in Port 1 is a Keil-specific operation i.e. The use of sbit keyword allows us to define bit variable which is already a part of some predefined byte-sized variable. Suppose if we wish to control 5th pin of PORT 1, we can use the following declarations: But in case we wish to control only the specific pins in a particular port. The above example is written to control the whole of port 1. Thus now we can straightforward access the ports to give appropriate instructions.Įven though we are referring to an address in the above definition the use (*) or indirection operator is not necessary since the compiler understands them by itself as SFRs. These addresses of ports are predefined in the reg52 file which is inserted as the source file using the #include pre-directive. If you wish to access these ports, we need to write these addresses.

SFRs denotes the physical address of these ports in the internal RAM: P0 is at address 0x80, P1 is at address 0x90, P2 is at address 0xA0 and P3 is at address 0xB0. There are four ports in an 8051 microcontroller and these are named as P0, P1, P2, P3 respectively. In order to control the ports, we need a function known as "Special Function Registers" (SFRs). In addition to performing some specific operations like controlling the access to external storage. All the ports are bidirectional in nature, which means they can perform both input and output operations. The 8051 microcontrollers have 8-bit ports.
#Assembly 8051 fibonacci how to
How to access Ports and Pins in 8051 Microcontroller Submitted by Sudarshan Paul, on June 21, 2018

In this article, we will discuss about how to access and write instructions for various ports and their specific pins through C programming using Keil?
