Delay Problem,Byte,Word


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    mmm, i think i may have spotted few problems...

    When you declare an array like this...
    Code:
    Array var BYTE[3]
    it will hold 3 different value. And they will be...
    Array[0]
    Array[1]
    Array[2]

    Not MUCH, if you Write to Array[3], the compiler won't complaint... but it will cause you some problem one day or another because you WILL overwrite x variable...

    so just modify your code and it should work better. In VB it work.. but it's a little bit different in PBP.

    Just for testing, try...
    Code:
    DelayArray  var byte[4]
        delayarray[0]=1
        delayarray[1]=10
        delayarray[2]=100
        delayarray[3]=200
    
    Delay       var word
    CounterA    var byte
    
    Start:
        for countera=0 to 3
            high PORTB.0
            delay=delayarray[countera]
            pause delay
            low PORTB.0
            pause delay
            next
        
        goto start
    at least it's working here
    Last edited by mister_e; - 31st December 2006 at 14:07.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Mister thank a lot I will try now your code,
    I try this too:
    Delay1 var Word
    Delay2 var Byte

    Delay1 = Datain[3] * Datain[4]

    if Delay1 < 256 then
    Delay2 = Delay1
    Delay1 = 0
    else
    Delay2 = 0
    endif

    Loop = (Datain[2] * 10)
    ''''''''''''''''''''''''''''''''''''''''''''Progra m 1''''''''''''''''''''''''''''''''''''''''''''''''' ''
    IF Datain[1] = 0 then
    for N = 0 to Widerholung

    High PortC.0
    High PortC.1
    low PortC.2
    low PortC.3

    Pause Delay1
    Pause Delay2

    low PortC.0
    High PortC.1
    high PortC.2
    low PortC.3

    Pause Delay1
    Pause Delay2

    low PortC.0
    low PortC.1
    high PortC.2
    high PortC.3

    Pause Delay1
    Pause Delay2

    high PortC.0
    low PortC.1
    low PortC.2
    high PortC.3

    Pause Delay1
    Pause Delay2

    Next N
    endif

    This Work ! :-)

Similar Threads

  1. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. RF Transmitter
    By et_Fong in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th October 2005, 16:34
  4. Memory Space of the PIC16F84...
    By Tear in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st July 2005, 19:55
  5. Problem with saving to EEPROM...
    By Tear in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st July 2005, 00:10

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