1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

generate time delay using timer

Discussion in 'Microcontrollers' started by shreyas_patel21, Jan 6, 2011.

  1. shreyas_patel21

    shreyas_patel21 New Member

    Likes Received:
    0
    Trophy Points:
    0
    how to generate 1 us time delay using timer module of pic
    i have the code for it
    here it is
    void delay(unsigned int us)
    {
    unsigned int x;
    T1CON=0x0000;
    for(x=0;x<us;x++)
    {
    TMR1=0x0000;
    T1CON=0x8010; //timer 1 enable with prescale of 1:8
    while(TMR1<0x02);
    T1CON = 0x0000;
    }
    }
    can anyone explain me why 0x02 is chosen for 1 us in TMR1.?
Loading...

Share This Page