Discussion in "8051 Discussion Forum" started by    romel_emperado    Nov 4, 2010.
Mon Nov 08 2010, 07:23 pm
#41
char * x; <- character pointer
char x[10] <- array of character or string
char *x[10] <- pointer to array of array of character or pointer to array of strings.
char **x <- pointer to a pointer that points to a character
Mon Nov 08 2010, 07:23 pm
#42
[Topic moved to 8051 Discussion Forum]
Mon Nov 08 2010, 08:05 pm
#43
@ajay, can i get exact 1 second delay by using TMOD?

if i would create a delay of 50ms X 20 = 1000ms = 1sec

what do u think? hehe it could be use in Digital clock? hehe i dont know..hehe
Mon Nov 08 2010, 08:16 pm
#44
yes u can use it...
 romel_emperado like this.
Mon Nov 08 2010, 09:32 pm
#45
i think this delay is not true 1sec ist more than a second.. hehe but anyway its okay Im just using this for testing. i will adjust the timing if everything is fix.. hehe

void delay(char k)
{
 char i; 
 TR0=0;
 for(i=0; i<k; i++)
 {
  TH0=0x3c;
  TL0=0xb0;
  TF0=0;
  TR0=1;
  while (TF0==0);
  TR0=0;
 }
}
Mon Nov 08 2010, 11:53 pm
#46
hi romel_emperado
debug ur code in keil to tune exact delay u want
Tue Nov 09 2010, 06:02 am
#47
hi majoka i dont know ho to debug using keil. Im just estimating the time in protues hehe

anyway, i create a 50ms delay inTMOD and i multiplied it to 20times to get 1sec delay but why it doesnt make difference if the value of K is lower that 20?


when i put a 1 value of k it is the same as 20. the delay is the same.

void delay(int k)
{
  int i;
  TR0=0;
  for(i=0; i<k; i++)
  {
    TH0=0x3c;
    TL0=0xb0;
    TF0=0;
    TR0=1;
    while (TF0==0);
    TR0=0;
  }
}
Tue Nov 09 2010, 07:54 am
#48
another question. how do i extend the strings that the array can handle?

let say for example the code below if put 60 strings it will get an error its limited to 40 strings..
char* sec1[]={"1","2","3","4","5","6","7","8","9"};
Tue Nov 09 2010, 10:21 am
#49



hi all weeee!! i finish the code of clock its now working.. i need to add now on how to set the clock and next the date..


#include <AT89X51.H>

#include "lcd.h"


void delay(char k)
{
  char i;
  TR0=0;
  for(i=0; i<k; i++)
  {
    TH0=0x01;
    TL0=0x00;
    TF0=0;
    TR0=1;
    while (TF0==0);
    TR0=0;
  }
}


char* sec1[]={"0","1","2","3","4","5","6","7","8","9","10"};
char i,s,tempsec,m,tempmin,h,temphour,am_pm,a=0;
char* romel[]={"am","pm"};



void main()
{
   TMOD=TMOD&0xF0;
   TMOD=TMOD|0x01;
   initlcd();


	
  while(1)
  {
        cursorxy(3,6);
        putstr(":");
		cursorxy(3,9);
        putstr(":");
	
		for(i=0; i<10; i++)
		{
	      delay(20);
	      
		  cursorxy(3,12);
	      putstr(romel[am_pm]);

		  cursorxy(3,4);
	      putstr(sec1[temphour]);//	hour2

		  cursorxy(3,5);
	      putstr(sec1[h]);		 //hour1

		  cursorxy(3,7);
	      putstr(sec1[tempmin]);   //min2

		  cursorxy(3,8);
	      putstr(sec1[m]);		 //min1

		  cursorxy(3,10);
	      putstr(sec1[tempsec]);  //sec2

	   	  cursorxy(3,11);
		  putstr(sec1[i]);		  //sec1
		  s++;
		  if(s==10){  	   
		  s=0;
		  tempsec++;}
		  if(tempsec==6){	
		  tempsec=0;
		  m++;}
		  if(m==10){   
		  m=0;
		  tempmin++;}
		  if(tempmin==6)  
		  {
		    tempmin=0;
			h++;

			if(h==10)	   
			{
			  h=0;
			  temphour++;
			  
			}
			if(temphour==1 && h==3)
			  {
			    h=1;
				temphour=0;

			  }
			else if(temphour==1 && h==2)
			  {
			    am_pm=1;  
				a++;
				if(a==2)
				{
				  a=0;
				  am_pm=0;
				}
			  }

		  }

	   }
  }
}



[ Edited Tue Nov 09 2010, 09:14 pm ]
Thu Nov 11 2010, 02:38 am
#50
hello what is the proper inserting of external interrupt in that above code?
i tried some but because i am using a loop to increement seconds my increment button also will effect after 10 seconds..
how to set this things up that when i press a increment button the minutes and hour will quickly increase or decrease and will not wait 10sec to take effect after pressing?

example:

void set() interrupt 0
{
if (increment==0)
m++;
}

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Clydehet
Wed May 01 2024, 06:44 pm
Davidoried
Wed May 01 2024, 06:11 pm
KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am