My learning thread - thanks everyone
Mon Nov 08 2010, 07:23 pm
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
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, 08:05 pm
@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
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, 09:32 pm
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; } }
Tue Nov 09 2010, 06:02 am
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.
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
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..
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
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
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:
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++; }
Powered by e107 Forum System