Seven Segment Display Interfacing With Timer Code | Operating System

Hello guys, welcome back to my blog. In this article, I will share the code of seven-segment display interfacing with the timer.
This code is tested many times in Keil software, there is no error in this code. Well, I will provide the code below to go and check. If you want an article on some other topics then comment us below in the comment section. You can also catch me @ Instagram – Chetan Shidling.
Seven Segment Display Interfacing With Timer Code | Operating System
Seven Segment Display Interfacing With Timer Code 
 
 

// SEVEN SEGMENT DISPLAY INTERFACING
#include <LPC21xx.H>
#define SELDISP1 0x10000000  // p0.28 select display 1
#define SELDISP2 0x20000000   // p0.29 select display 2
#define ALLDISP 0x30000000    // select both display
void InitTimer0(void);// to initialize timer 0
//declare the seven segment display data
unsigned int array_dec[16]={0x003F0000, 0x00060000,
0x005B0000, 0x004F0000, 0x00660000, 0x006D0000,
0x007D0000, 0x00070000, 0x007F0000, 0x006F0000,
0x00770000, 0x007c0000, 0x00390000, 0x005E0000,
0x00790000, 0x00710000};           
unsigned int disp_count=0, disp_mux=0,
                                                                                                                                                                               
temp1=0, count_255=0, temp_data=0;
unsigned long int temp2=0x00;
char arr1[] = { 0x00 , 0x00 }  ; // tens and units
int main(void)
{
PINSEL1 = 0X00000000;
IO0DIR  = 0X30FF0000;
InitTimer0();
T0TCR = 0x01;
               
while(1); // wait for the interrupt
}             
               
// Timer0 isr
void timer0_isr(void) __irq
{
IO0CLR = ALLDISP; // DISABLE BOTH 7-SEG
               
count_255++;
if(count_255 == 256)
{
count_255 = 0;
                                                 
arr1[0] += 0x01;
if(arr1[0] == 0x10)
{
arr1[0] += 0x00;
arr1[1] == 0x01;
}
if(arr1[1] == 0x10)
arr1[1] = arr1[0] = 0x00;
}
if(disp_count==0)
{
disp_mux=SELDISP2;
temp1 = arr1[0];
                                                               
temp1 &= 0x0F;
temp2 = array_dec[temp1];
}
                                               
else if(disp_count==1)
{
disp_mux=SELDISP1;
           temp1 = arr1[1] ;
                                                                               
           temp1 &= 0x0F;
           temp2 = array_dec[temp1];
}
                disp_count++;
                                               
                IO0SET = disp_mux;
                                               
                temp_data = IO0PIN;
                temp_data &= 0x00FF0000;
                IO0CLR = temp_data;
                IO0SET = temp2;
                                                 
                if (disp_count == 2)
                disp_count = 0;
                T0IR |= 0x01;
                VICVectAddr=0;
}
               
//void timer0_init(void)
void InitTimer0(void)
{
                T0MR0 = 6000;
                T0MCR = 0X00000003;
               
                VICVectAddr0 = (unsigned long)timer0_isr;
                VICVectCntl0 = 0x20|4;
                VICIntEnable |= 0x00000010;
               
                T0TCR = 0x00000001;
}