Time diference in microseconds


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default It works... !??

    Thank´s a lot...
    I suppose your code works but I don´t think these week I´ll have time to test it, because I´m working with the hardware...
    But when I have news I´ll tell you.
    Regards
    Leonel Monteiro

  2. #2
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default wrong time

    Can anybody explain me what´s wrong in these code...
    I want to turn led on and off in each 5 seconds, but it didn´t wait 5 seconds. It is much less, about 50ms
    Sorry but variables and comments are in portuguese

    'este ficheiro é apenas para testar algumas funcionalidades da placa

    DEFINE OSC 4 'o programa irá correr a 4MHz

    ADCON1 = $06 'indica que todas as entradas são digitais
    TRISA = $3F 'estou a colocar RA.0, RA.1, RA.2, RA.3, RA.4 e RA.5 como entradas e o resto como saídas
    TRISB = $FF 'estou a colocar tudo como entradas
    TRISC = $00 'estou a colocar tudo como saídas
    variavel var word
    start:
    portc.3 = 1
    gosub tempo_ligado
    portc.3 = 0
    portc.2 = 1
    gosub tempo_ligado
    portc.2 = 0
    portc.1 = 1
    gosub tempo_ligado
    portc.1 = 0
    goto start

    tempo_ligado:
    T1CON.0 = 1 'inicio o timer
    while variavel < 80
    if pir1.0 = 1 then
    variavel = variavel + 1 'a variavel incrementa a cada 0.06seg.
    'colocando a 80 esperamos 5seg
    endif
    wend
    pir1.0 = 0
    T1CON.0 = 0 'paro o timer
    variavel = 0
    TMR1L = 0
    TMR1H = 0
    return

  3. #3
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Try ....

    tempo_ligado:
    T1CON.0 = 0 'paro o timer
    pir1.0 = 0
    variavel = 0
    TMR1L = 0
    TMR1H = 0
    T1CON.0 = 1 'inicio o timer
    while variavel < 77
    if pir1.0 = 1 then
    variavel = variavel + 1 'a variavel incrementa a cada 0.06seg.
    'colocando a 80 esperamos 5seg
    pir1.0 = 0
    endif
    wend
    T1CON.0 = 0 'paro o timer
    return

  4. #4
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Thank´s...
    Your code works.

Similar Threads

  1. Hello, long time no post (ADC sample rate)
    By Jhong2 in forum General
    Replies: 0
    Last Post: - 14th April 2009, 05:13
  2. I don't understand this code!
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 13th February 2008, 03:55
  3. Measuring time
    By AugustoPedrone in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st July 2007, 00:46
  4. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 20:55
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 15:24

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts