Delay is twice that of Keil and Proteus simulator

Discussion in 'General Electronics Chat' started by Tera-Scale, Jun 19, 2013.

  1. Tera-Scale

    Thread Starter Active Member

    Jan 1, 2011
    164
    5
    I am using a timer delay with polling method. Every thing works fine execpt that when implementend on my dev board, the true delay is twice that of Keil and Proteus simulator. Every crystal frequency setting is correct. Any ideas. I tried to check the X2 in the hardware byte option
    in flip but then my UART communication was effected and did not work correctly because of the baud rate being doubled. I had to vary the baud rate on my PC and then it worked fine. Is there any other solution for this problem?

    Code ( (Unknown Language)):
    1. void delay_10m()            // Delay generation using Timer 0 mode 1
    2. {
    3.     TMOD = 0x01;            // Mode1 of Timer0
    4.     TH0= 0xC3;              // C33FF = 10millisecond delay
    5.     TL0 = 0xFF;
    6.     TR0 = 1;                // Start Timer
    7.     while(TF0 == 0);        // Polling method
    8.     TR0 = 0;                // Stop Timer
    9.     TF0 = 0;                // Clear flag
    10. }

    ucont : T89C51AC2
    XTAL : 18.432Mhz
    Keil: Uvision V4.60.00.0
     
Loading...