#include<reg51.h> void delay() //Function to provide a time delay of approx. 1 second. Timer 1. { int i; for(i=0;i<20;i++) { TL1=0xFD; TH1=0x4B; TR1=1; while(TF1==0); TR1=0; TF1=0; } } void main() { char num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};// Hex values corresponding to digits 0 to 9 int c; while(1) { for(c=0;c<10;c++) { P1=num[c]; delay(); } } }
Hi guys, I am not getting delay of 1 sec.blinking rate of 7 segment is too fast in comparison of delay calculated(=1sec). Any help will be appreciated.. thanks
According to what calculation???
4BFD(hex)=19453(decimal) {65536-19453)*1.085=50000.055us=0.05sec 20*0.05=1sec
Hi Abass,
I did one of these delays. and i am very good at them.
You are running at 11.95MHz Crystal. or 7.213MHz?
Did you consider including the hydrodifferential inductocapacitive deviation value in your calculation.
If you can't do that, why not give us the formula you use for the calculation.
I just used the formulae given in MAZIDI . Convert the hexadecimal value to decimal and then subtract with 65536 and then multiply with 1.085 to get exact delay. Crystal frequency used is 11.95MHz
What delay are you getting?
and then multiply with 1.085 to get exact delay.
C'mon mate, tell us where the 1.085 comes from.
Convert the hexadecimal value to decimal and then subtract with 65536
WTF is the hexadecimal value? And I don't mean the actual value you use, I mean what does the value represent?
If YOU can answer these, you'll be one step closer to understanding what you've got wrong.
Hi, Using 11.0812MHz Crystal and P89V51RDFN2 uC unit. Using it in 1/12 clock cycle mode so that 1/12 of 11.0592 is one T state. For it 1/12 * 11.0592 is effective clock. Which is 12/11.0592= 1.085us in time domain. and for one second delay, a loop of 20 iterations with each iteration of approximately 50000us is calculated as 50000/1.085=46080 or for approx calculations 46083 and for time with this delay initialization id done at 65535-46083+1=19453 (+1 u can understand, if not leave it its very small since we are talking about 1 second not milliseconds). What we didn't get here guys?
Where do you set up the TIMER/COUNTER MODE CONTROL REGISTER?
here we go again
WHICH CHIP? (8051 can mean a lot of things these days)
View all questions in Keil forum