0% found this document useful (0 votes)
17 views2 pages

PIC16F84A Programming Guide

The document outlines an embedded system programming project using an 8051 microcontroller in C language. It involves: 1) Performing a built-in test of 4 input pins and displaying the results on an LCD. 2) Creating a 3 second delay to display countdown on LCD before showing "System Ready". 3) Using a timer counter to wait for 8 pulses before displaying a message. 4) Reading 4 bytes of data from port 2 based on the states of input pins. 5) Creating an 8 byte data block with identifiers, read data and checksum and transmitting it serially. 6) Repeating steps 3-5 indefinitely.

Uploaded by

Raees Ahmed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

PIC16F84A Programming Guide

The document outlines an embedded system programming project using an 8051 microcontroller in C language. It involves: 1) Performing a built-in test of 4 input pins and displaying the results on an LCD. 2) Creating a 3 second delay to display countdown on LCD before showing "System Ready". 3) Using a timer counter to wait for 8 pulses before displaying a message. 4) Reading 4 bytes of data from port 2 based on the states of input pins. 5) Creating an 8 byte data block with identifiers, read data and checksum and transmitting it serially. 6) Repeating steps 3-5 indefinitely.

Uploaded by

Raees Ahmed
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

(Complex Engineering Problem)

You have to make the following embedded system using 8051 Microcontroller and
do
the programming in C-Language.

1. Built in test
4 inputs are connected to P1.0 to P1.3 pins of controller. When 8051 will start
it will check these lines individually. If signal is high at any of the pins do the
following: -
P1.0 high => Print “System 1 Faulty” on LCD
P1.1 high => Print “System 2 Faulty” on LCD and so on.
If no pin is high than print “All systems are OK” on LCD.

The LCD is connected to Port 0 and remaining pins of P1 (i.e. P1.4 to P1.7)

2. Wait for 3 Seconds


a. Use different set of instructions to create a delay of 3 seconds. During
this time the display of LCD should be shown as 3 secs, 2 secs, 1 sec
after each passing second.
b. Finally, after 3 seconds it should display “System Ready”.

3. Use of Timer/Counter
Now set Timer 0 in counter mode such a way that the program waits for 8
pulses to arrive. Once 8 pulses are arrived. Send message on LCD “8 Pulses
Arrived”.

4. Getting data from port 2


Now you have to get 4 bytes of data from port 2.

Hence wait for P1.0 to be high, when it is high send 00 to P3.6 and P3.7 and
read data from Port 2 and save it.

Now wait for P1.1 to be high, when it is high send 01 to P3.6 and P3.7 and
read data from Port 2 and save it.

Repeat the process for P1.2 and P1.3 to be high. Hence, at the end you
will have four bytes.

It is to be ensured that in program you have to ensure that you have to


declare P1.0 (P1.1, P1.2 and P1.3) declared 1 if it remains one for at least 20
msec.

5. Making a data block and send it on serial link


Now you have to make a data block of 8 Byte as under:

5A, 6B, 7C, 4 bytes of data gathered in step 5. The last byte will be XOR of all
7 previous bytes.
Once this block is ready send each byte if the block serially one by one using
serial port at a Baud rate of 9600 and a protocol of 1 start bit 8 data bits and 1
stop bit.

Repeat the program from step 3 forever.

Common questions

Powered by AI

Distinguishing signal states using outputs on P3.6 and P3.7 simplifies the data acquisition process by clearly identifying which port signal condition prompts data capture from Port 2. By sending different binary signals ('00', '01', etc.), the system reliably decodes which specific event has occurred on Port 1, thus organizing the byte-reading procedure in a sequential and logical manner .

Relying on signal conditions allows the microcontroller to trigger specific actions based on precise input states, which minimizes unnecessary processing and improves response time. This method is advantageous in real-time systems as it enables instant reaction to signal changes, facilitating efficient data handling and management with minimal delay, while ensuring resource optimization .

The 8051 microcontroller system implements a strategy where on startup, it checks the state of the P1.0 to P1.3 pins. If any pin is high, it prints a fault message corresponding to the pin on an LCD. For instance, if P1.0 is high, it prints 'System 1 Faulty'. If none of the pins are high, it prints 'All systems are OK'. This allows the system to quickly identify and report any initial faults in the connected inputs .

The 8051 microcontroller collects four bytes of data from Port 2 when specific conditions are met on Port 1. Initially, it waits for P1.0 to be high, then sends the signal '00' to P3.6 and P3.7 and reads a byte from Port 2. This is repeated for P1.1, P1.2, and P1.3, each time using unique signals ('01', '10', '11' respectively) to gather data. Additionally, each pin on Port 1 must be high for at least 20 milliseconds before data is read, ensuring signal stability .

The 8051 microcontroller utilizes Timer 0 in counter mode to wait for eight pulses to arrive. Once these pulses are detected, it prints the message '8 Pulses Arrived' on the LCD. This mechanism of counting pulses allows the system to track specific events accurately and communicates these results in real-time through the LCD interface, providing operators with immediate feedback .

The 8051 microcontroller uses a sequence of instructions to create a delay of 3 seconds. During this period, it updates the LCD display every second to show a countdown of '3 secs', '2 secs', and '1 sec'. After the 3-second countdown, it displays 'System Ready' on the LCD. This process involves controlled timing to ensure precise message transitions on the display .

Serial communication is used in the system to transmit a constructed 8-byte data block. It is configured to operate at a Baud rate of 9600 with a format of 1 start bit, 8 data bits, and 1 stop bit, providing a standardized and reliable method for data transfer. This configuration supports efficient and straightforward integration with other devices requiring serial communication .

The 8051 microcontroller requires that each input pin on Port 1 remains high for at least 20 milliseconds before being declared definitively high. This technique ensures stability and prevents false triggering due to momentary noise or glitches in the input signals, thus allowing more reliable data acquisition .

The data block construction involves assembling the bytes 5A, 6B, 7C, followed by four gathered data bytes. The final byte is computed as the XOR of all seven preceding bytes, ensuring data integrity. This 8-byte block is then transmitted serially, one byte at a time, at a Baud rate of 9600 with a protocol of 1 start bit, 8 data bits, and 1 stop bit. The XOR byte acts as a checksum for validation post-transmission .

Repeating the program from step 3 onwards allows continuous operation of the embedded system, enabling constant monitoring of input pulse events and subsequent data handling. This design ensures that the system functions in real-time, efficiently managing data flow and responding dynamically to new inputs or changes without the need for restarting the system from an initial reset state .

You might also like