Menu

Wait time not correct

2008-06-23
2013-05-30
  • Nobody/Anonymous

    i us the compiler with e 16f88 4Mhz device.
    when i check it with MpLap (or real) i see that the delay time PULSOUT is not correct i get
    about 1300us why?

    #chip 16F88,4
    .
    .
    .

    REPEAT 15
    PULSEOUT PORTB.0, 100 10us
    WAIT 18 ms   
    END REPEAT

    it looks like the DELAYTEMP in the sub-Delay_10US is not right...

     
    • kent_twt4

      kent_twt4 - 2008-06-23

      Well I'm going to have to pile on here also.  Not good if you are trying to time a servo signal, run a Uart, etc.  Was trying to debug the soft Uart or SerSend routine with the 10us delays.  Results of testing the us, ms, and 10ms second delay routines with TMR1 came out pretty good.

      Here's a TMR1 example of 18f4620, with a 20mhz clock, and prescaler of 1:4 for a 1.25us/cyle clock.  Too lazy to hook up the lcd so reading out four leds in hex, I get:
      0x029C or 668us/1.25 = 534us, ouch! (should be 500us).

      My stabs at changing the DELAYTEMP, "L", or the inner loop didn't go well, much less have an effect on the assembler.

      'Chip model
      #chip 18f4620,20
      #config MCLRE=ON, OSC=HS, LVP=OFF
      #define Led PortA.0
      dir PortA.0 out
      dir PortD out
      InitTimer1 Osc,PS1_1/4

      Main:
      Set Led On
      wait 1 s
      ClearTimer 1
      StartTimer 1
      wait 50 10us
      ;wait 42 10us
      StopTimer 1
      Set Led Off
      PortD = swap4(TMR1H) 'Led's on PortD <3:0>
      wait 3 s
      PortD = 0
      PortD = TMR1H
      wait 3 s
      PortD = 0
      PortD = swap4(TMR1L)
      wait 3 s
      PortD = 0
      PortD = TMR1L
      wait 3 s
      Goto Main

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.