Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/13/07 12:48
Read: times


 
Msg Score: -2
 -2 Didn't Search First
#134848 - CLOCK WITH 7SEGMENT DISPLAY
/*sory my english not good

i had made clock schematic with 7 segment display multiplexed with 8 transistor for selector digits(PNP transistor), databit segment use in P1,and the digit selector in P0
I used microcontroler AT89S8252,I used C language and It's work well, now I had problem with my project that i want add my schematic with RTC DS1307, for setting alarm clock. However i dont know how to acces the RTC DS1307 in C language ? any one can help me?plzz..
P1-->data segement
P0-->selector of transistor
C compiler : SDCC


this my small program for Clock in 7 segment display multiplexed
that i had used
*/

#include<AT89X51.h>
char Pencacah20;
char Secon;
char Minute;
char Hour;

char Segmen[6];//
sbit at 0xA0 Hour_Button ;
sbit at 0xA1 TombolMinute ;
sbit at 0xA2 Secon_Button ;
sbit at 0xA3 INC_Hour_Button;
sbit at 0xA4 INC_Minute_Button;
sbit at 0xA5 INC_Secon_Button;

//****** array number 0-9 *******
void Segmen2Digit (unsigned char c, unsigned char pos){
code char Segmen_Com[]={0x01,0xC7,0x22,0x82,0xC4,0x88,0x08,0xC3,0x00,0x80};
Segmen[pos++] = Segmen_Com[c/10];
Segmen[pos] =Segmen_Com[c%10];
}

void Change_View (void){
Segmen2Digit(Hour,0);
Segmen2Digit(Minute,2);
Segmen2Digit(Secon,4);//
}

//******Delay time 1 digit number*******
void WaitMomen() {//wait 1m secon

TH1=(-1500/256)-1;
TL1=(-1500%256);
TF1=0; //Timer Flag 1 =0
TR1=1;
while (!TF1);
}
//****Main program******************************************

void main (void) {
Pencacah20=20;
Hour=Minute=Secon=0;
Change_View();

TH0=(-50000/256)-1;
TL0=(-50000%256);

TMOD=0x11;
ET0=1;
EA=1;
TR0=1;

while(1)
{
P1=Segmen[0];
P0=0xDF;
WaitMomen();
P1=Segmen[1];
P0=0xEF;
WaitMomen();
P1=Segmen[2];
P0=0xF7;
WaitMomen();
P1=Segmen[3];
P0=0xFB;
WaitMomen();
P1=Segmen[4];
P0=0xFD;
WaitMomen();
P1=Segmen[5];
P0=0xFE;
WaitMomen();
}
}
//1111 1111
//**********change Hour digit*************

void ChangeHour (void){
Hour +=1;
if (Hour==24){ Hour = 0 ;
Change_View();
}
}


void ChangeMinute(void){
Minute +=1;
if (Minute==60){
Minute = 0 ;
ChangeHour(); }
Change_View();
}


void ChangeSecon(void) {
Secon +=1;
if (Secon==60) {
Secon=0;
ChangeMinute(); }
Change_View();
}



void Increment_Hour(void) {
Hour -=1;
if(Hour==0) {
Hour=24;
Change_View();
}
}

void Increment_Minute(void){
Minute -=1;
if (Minute==0){
Minute =59 ;
Increment_Hour(); }
Change_View();
}

void Increment_Secon(void) {
Secon -=1;
if (Secon==0) {
Secon=0;
Increment_Minute(); }
Change_View();
}



void Check_Button (void) {
if (!Hour_Button) ChangeHour();
else
if (!TombolMinute) ChangeMinute();
else
if(!Secon_Button) ChangeSecon();
else
if(!INC_Hour_Button) Increment_Hour();
else
if(!INC_Minute_Button) Increment_Minute();
}


void TimerInterrupst(void) interrupt 1 using 1 {


TH0=(-45000/256) -1;
TL0=(-45000%256);

Pencacah20 -=1;
if (!Pencacah20) {
Pencacah20=20;
Check_Button();
ChangeSecon(); }
}








List of 3 messages in thread
TopicAuthorDate
CLOCK WITH 7SEGMENT DISPLAY            01/01/70 00:00      
   formatting helps            01/01/70 00:00      
   Didn't search first            01/01/70 00:00      

Back to Subject List