Microcontroller › 8051 › 7 segment with 8051 using interrupt
- This topic has 1 reply, 2 voices, and was last updated 10 years, 11 months ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
February 17, 2014 at 2:43 pm #2870Amit RaijadeParticipant
i want to display set-01 on seven segment display using interrupt
i have attached code for it
but not working well
#include <reg51.h>#define PORT_SEVEN_SEG P0#define blank 0x00sbit dig0 = P2^1;sbit dig1 = P2^2;sbit dig2 = P2^3;sbit dig3 = P2^4;sbit dig4 = P2^5;sbit dig5 = P2^6;unsigned char data display_arr[6], bcdval[6], dig_count, l_display_arr[6];//void pin_status();void initialize();/*void delay(unsigned int ms){int i, j;for(i=0;i<ms;i++)for(j=0;j<300;j++);}*/void main(){int i,j=0;code unsigned char Setup1[] = {0x15,0x91,0xD1,0xFD,0x03,0x6F}; //set-1initialize();EX0 = 1;for(i = 0; i < 6;i++){display_arr = Setup1;//delay(1);}EX0 = 0;}void initialize(){P0 = blank; //segments offP2 = 0xfe; //digits off//P1 = 0xff;TMOD = 0x00; //gate1, c/t1, m1, m0, gate0, c/t0, m1, m0// 0 0 1 0, 0 0 0 1 timer1 8 bit, timer0 16 bit;TCON = 0x11; //timer1 flag, timer1 on,//timer0 flag, timer0 0n,//ext int1 flag, ext int1 edge/low-(1/0), ext int0 flag, ext int0 edge/low-(1/0)PCON = 0x00; //smod, res, res, res,//gf1, gf0, pd, idlSCON = 0x40; //sm0, sm1, sm2 (mode 01 8 bit var baud),//recv_enb ,tb8,rb8,ti,riIE = 0x82; //enable all, res, enable timer2, enable serial,//enable timer1 , enable extint1, enable timer0, enable extint0TH1 = 0xfA; //f4_2400, fd_9600, fa_4800, e8_1200TL1 = 0xfA;TH0 = 0x78;TL0 = 0x00;//TR0 = 1;}void timer0() interrupt 1{TH0 = 0x78;TL0 = 0x00;P0 = 0xff;if(dig_count == 6)dig_count = 0;switch(dig_count){case 0: dig0 = 0;dig1 = 1;dig2 = 1;dig3 = 1;dig4 = 1;dig5 = 1;break;case 1: dig0 = 1;dig1 = 0;dig2 = 1;dig3 = 1;dig4 = 1;dig5 = 1;break;case 2: dig0 = 1;dig1 = 1;dig2 = 0;dig3 = 1;dig4 = 1;dig5 = 1;break;case 3: dig0 = 1;dig1 = 1;dig2 = 1;dig3 = 0;dig4 = 1;dig5 = 1;break;case 4: dig0 = 1;dig1 = 1;dig2 = 1;dig3 = 1;dig4 = 0;dig5 = 1;break;case 5: dig0 = 1;dig1 = 1;dig2 = 1;dig3 = 1;dig4 = 1;dig5 = 0;break;}P0 = display_arr[dig_count];TF0 = 0;dig_count++;}void int1() interrupt 2{ }void timer1() interrupt 3{ }void rec() interrupt 4{ }February 19, 2014 at 4:52 am #11056Ashutosh BhattParticipantyou have not specified which interrupt you want to use
in your program you are enabling external interrupt 0 but your ISR is for timer 0 interrupt (interrupt 1 keyword is for timer 0 interrupt)
also you have not enabled globle interrupt
use IE = 0x81 to enable external interrupt 0
and IE = 0x82 to enable timer 0 overflow interrupt
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.