Skip to content

Projects I made in Introduction to Microcomputers. I use MPLAB X IDE v5.20 for my projects.

License

Notifications You must be signed in to change notification settings

sudecakmak/Microcomputers

Repository files navigation

Microcomputers

Projects I made in Introduction to Microcomputers. I used MPLAB X IDE v5.20 for my projects.

I am going to use PIC16F877A.

I write my codes in assembly. The C coded version of my programs are showing in the pictures.

Table of Contents

Microcomputer

A microcomputer is a complete computer on a small scale, designed for use by one person at a time. An antiquated term, a microcomputer is now primarily called a personal computer (PC), or a device based on a single-chip microprocessor. Common microcomputers include laptops and desktops. Beyond standard PCs, microcomputers also include some calculators, mobile phones, notebooks, workstations and embedded systems.

Microcontroller

A microcontroller (MCU) is an integrated circuit that combines CPU, program and data memory, EEPROM, Timers, several GPIO ports, communication interfaces such as UART, USB, I2C, SPI, CAN etc. into a single chip, and is programmed to do a specific task.

Arithmetic and Logical instructions

The program shows below arithmetic expression how to write in assembly.

C code

Screenshot 2022-10-23 132934

Conditional expressions

The program shows which of the boxes shown in the figure will be in the region where the written x and y values are located.

Screenshot 2022-10-29 135157

C code

Screenshot 2022-10-29 135217

Loops and Delay functions

Program display each and every Zibonacci number from 2 to 13 within the while loop on the LEDs, and waits for the user to press Button3 (RB3 on PICSIM) to move on to the next iteration of the loop. Also makes a 250ms delay before checking if the button is pressed and moves on to the next iteration of the loop.

C code

Screenshot 2022-11-10 153821

Function calls and Indirect addressing

Consider an arbitrary number generator function GenerateNumbers that takes 3 arguments, x, y and N, and generates some arbitrary numbers in a loop, and stores these numbers in an array. It then returns the total number of elements generated and stored in the array. You then write another function AddNumbers that adds the numbers in the array and returns their sum. You write a function DisplayNumbers that first displays the sum and then the first 5 numbers in the array one after the other as the user presses Button3 connected to PORTB3 (RB3 on PICSIM).

C code

Screenshot 2022-11-25 014056

Led

The idea is to walk over the LEDs first from the right to the left lighting up one LED at a time. When we have reached the last LED, we change direction and start walking to the right until we reach the first LED. This completes a cycle. When the cycle is completed, we flash the LEDs twice.

C code

Screenshot 2022-12-06 121602

Seven Segment Display

The goal of this lab is to make use of the Seven Segment Displays (SSD) connected to PORTD of PIC16F877A on PICSIM. Recall that the SSD to be lit up is first selected by making its selection bit A2-A5 HIGH. Thus, to display a value on the first SSD (DIS4 on PICSIM), we first set A5 to logical 1 (HIGH), and then write the appropriate value corresponding to the number to be displayed to PORTD. The bit sequence necessary to display each number was discussed in class.

You are asked to implement a simple counter that starts at 0 and counts up to decimal 20. When your counter reaches 20, it goes back 0 and counts up again. You counter must increment every second.

The most important thing in implementing this project is to avoid flicker on the SSDs. Notice that you will be displaying a two digit number, i.e., you will be displaying a value on the first and second SSDs (DIS3 & DIS4 on PICSIM). To display the counter, make sure that you select and display the first digit on the first SSD (DIS4). Then wait for 5ms so that the LEDs on the first SSD light up completely. Then select the second SSD (DIS3) and display the second digit on the second SSD. Again wait for 5ms to make the LEDs on the second SSD to light up completely.

So far you displayed the two digit number on both SSDs and spent about 10ms. Before you increment your counter, you need to wait for another 980ms. If you simply wait for 980ms in an idle loop now, your first SSD will turn off and you will not be able to see the first digit anymore! To avoid this problem, write a display loop that iterates for some number of iterations (NO_ITERATIONS). Within the loop, display the first digit and wait for 5ms. Then display the second digit and wait for 5ms. Thus, the two digit number will be visible on the SSDs all the time. When the loop terminates, you have spent about 1000ms, i.e., 1 second. You can increment your counter and go back to the beginning of the main loop to display this number. Make sure that after your counter reaches 20, it rolls back to 0 and counts up from there.

C code

Screenshot 2022-12-09 235906

LCD

Counter value starts at 0, increments every second by 1 up to 20 and then rolls over back to 0. On the first line of the LCD displays two digits. For example, if the counter value is 12, then the first line must show “Counter Val: 12”. The second line of the LCD will show the message “Counting up…” if the counter is less than or equal to 20. When the counter rolls over from 20 to 0, the counter value will display 00, and the second line will show “Rolled over to 0”. At the next increment, you then show “Counting up…” as usual.

C code

Screenshot 2022-12-18 144753

Output

Screenshot 2022-12-17 153718

Screenshot 2022-12-17 153653

Implementing a Counter Using Buttons

A simple counter that can be incremented, decremented or reset to 0 using 3 buttons connected to pins 3, 4 and 5 of PORTB. The counter will start at 0 and go up to 9. If the counter is incremented when its value is 9, it will roll over to 0. If the counter is decremented when its value is 0, it will go back to 9. Any time the reset button is pressed, the value of the counter becomes 0.

The first button (the button connected to PORTB3) will be used to increment the counter. The second button (the button connected to PORTB4) will be used to decrement the counter. The third button (the button connected to PORTB5) will be used to reset the counter. The value of the counter will be displayed on the first SSD on the experiment board.

C code

Screenshot 2022-12-19 183823

Output

ezgif-4-12d7526a66

About

Projects I made in Introduction to Microcomputers. I use MPLAB X IDE v5.20 for my projects.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published