Loading ...
Sorry, an error occurred while loading the content.

TIMER DELAY

Expand Messages
  • zulumanten
    HELLO, I am unable to get the proper delay on the oscilloscope, (e.g. on pin 4.2) USING TIMERS (timer0 or timer1). If I want a delay of 1msec, I usually get a
    Message 1 of 3 , Mar 15, 2008
    • 0 Attachment
      HELLO,
      I am unable to get the proper delay on the oscilloscope, (e.g. on
      pin 4.2) USING TIMERS (timer0 or timer1). If I want a delay of
      1msec, I usually get a higher value delay, the main code is;


      int main() //in aduc7024 40960000 instruction/sec is the max
      processing speed
      {
      WHILE(1) //infinite loop
      {
      T1LD=0*0A000; //40960000 * 0.001 = 40960 =A000 hex
      T1CON=0*0C0;
      GP0CON = 0×00; // for p4.2
      while(T1VAL!=0){} //wait for the t1ld value to become zero
      GP4DAT ^= 0×04000000; //complement pin 4.2 level
      T1CON0;
      }
      }

      The powcon and pllcon registers are both 0. To get the desired
      result what changes do I need to make?
      Maybe changes in cstartup.s file are required?...I dont know
      anything about cstartup, cant I declare the register values in my C
      code?...
      Any ideas anyone?...
    • cevague
      Hello, Maybe you should not wait to read the exact value 0x00000000. As you need several instructions to read the timer value and compare it, it is most likely
      Message 2 of 3 , Mar 17, 2008
      • 0 Attachment
        Hello,
        Maybe you should not wait to read the exact value 0x00000000. As you
        need several instructions to read the timer value and compare it, it
        is most likely that you'll miss the time it is equal to 0 (as it is
        configured as a free running counter). You'd rather use a compare
        output if you only want to toggle the pin, or in conjunction with an
        interrupt.
        Regards,
        --- In ADuC_ARM@yahoogroups.com, "zulumanten" <zulu_man10@...> wrote:
        >
        > HELLO,
        > I am unable to get the proper delay on the oscilloscope,

        > while(T1VAL!=0){} //wait for the t1ld value to become zero
        > Any ideas anyone?...
        >
      • zulumanten
        Hello, The timer from the t1con as you can see is not in free running mode but periodic mode. I have used both keil and IAR compilers, on IAR the program runs
        Message 3 of 3 , Mar 17, 2008
        • 0 Attachment
          Hello,
          The timer from the t1con as you can see is not in free running mode
          but periodic mode. I have used both keil and IAR compilers, on IAR
          the program runs fine with TxVAL register comparison with 0 in an
          infinite loop as you can see from the example but even after adding
          the ....

          powkey1=0*1;
          powcon=0;
          powkey2=0*F4;
          pllkey1=0*AA;
          pllcon=0*01;
          pllkey2=0*55;

          values the timer does not work as planned, as if the uC is still
          workig in 40.96MIPS / 16 mode, i.e. the delays are not predictable,
          the results without these pll and pow registers are not very
          different, in short the result of the timer is inaccurate.
          To calculate timer delay I use formula

          TxLD
          ----- = x sec delay
          40.96MIPS

          But when I run the same code on keil the results are predictable,
          i.e. as desired as its working in 40.96MIPS mode, but using
          interrupts,(in IAR while using interrupts the results were the same
          i.e. inaccurate exactly like while using TxVAL comparison
          technique). But when in keil I try to compare TxVAL value , the
          program stucks at the delay while loop.

          In IAR, I use ROM monitor, I dont have jtag, while in keil I just
          use simulator and then load the program using ARMWSD software and
          monitor the delay results using an OSCILLOSCOPE on pin4.2.
          I am posting the source code again

          #include<aduc7024.h>
          int main() //in aduc7024 40960000 instruction/sec is the max
          //processing speed
          {
          WHILE(1) //infinite loop
          {
          T1LD=0*0A000; //loading timer1,40960000 * 0.001 = 40960 =A000 hex
          T1CON=0*0C0; //start timer1
          GP0CON = 0×00; // cofig for p4.2

          while(T1VAL!=0) //wait for the t1ld value to become zero
          {} //delay loop
          GP4DAT ^= 0×04000000; //complement pin 4.2 level
          T1CON=0; //stop timer1
          }
          }


          --- In ADuC_ARM@yahoogroups.com, "cevague" <cagouilles@...> wrote:
          >
          > Hello,
          > Maybe you should not wait to read the exact value 0x00000000. As
          you
          > need several instructions to read the timer value and compare it,
          it
          > is most likely that you'll miss the time it is equal to 0 (as it is
          > configured as a free running counter). You'd rather use a compare
          > output if you only want to toggle the pin, or in conjunction with
          an
          > interrupt.
          > Regards,
          > --- In ADuC_ARM@yahoogroups.com, "zulumanten" <zulu_man10@> wrote:
          > >
          > > HELLO,
          > > I am unable to get the proper delay on the oscilloscope,
          >
          > > while(T1VAL!=0){} //wait for the t1ld value to become zero
          > > Any ideas anyone?...
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.