Activity 1. Three seven segment displays

The purpose of the activity is to display the number 123 on three seven-segment displays.

(30 minutes)


Activity 1


Step 1. The circuit is drawn in the Proteus Design Suite.



Step 2. The program in C language is written.

Write in CCS C Compiler the program in C language

#include <main.h>

#byte PORTB=0xF81

//define PORTB data register   

#byte PORTC=0xF82

//define PORTC data register

 

void main()

{

 set_tris_b(0x00);     // define PORTB as output

 set_tris_c(0x00);     // define PORTC as output

 

 while (TRUE){      

 // the codes of each digit are sent every 5 ms

 // by activating the corresponding display

 

//……Number 3    

PORTC=0b00000001; //activate the right display

PORTB=0b01001111; //code for “3”

delay_ms(5); 

 

//…….Number 2

PORTC=0b00000010; // activate the middle display

PORTB=0b11011011; //code for “2.

delay_ms(5);       

 

//………Number 1

PORTC=0b00000100; //activate the left display

PORTB=0b00000110; //code for “1”

delay_ms(5);   

   }

}


Step 3. Compile the program in C in order to create the program in the microcontroller machine code (hex file).



Step 4. Load to the microcontroller the hex file (program in machine code) that was created from the CCS C Compiler.



Step 5.  Run the simulation and check the correct operation of the circuit.