programming error.. plz help


Results 1 to 5 of 5

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Here's my version... we will check the switch action inside delay procedure.

    Code:
    'Objective to turn LEDS on and off at the same time
    
    DEFINE OSC 20
    
    
    Duty    VAR Word
    Cycle0  VAR BYTE
    Cycle1  VAR BYTE
    cycles  VAR Word
    Switch  Var PORTC.6
    DelayV  VAR BYTE
    
    TRISB = %00000000
    TRISC = %01000000
    
    start:
    
         Cycle1 = 2
    
    
    
    Loop:
    
    ;sequence 1
    ;==========
    
    For Duty = 0 to 2000 'ALL OFF ---> All ON 
         For cycles = 0 to Cycle1
              Portb = %00000000 
              DelayV=2000-Duty    
              Gosub DelayUs
              Portb = %11110000
              DelayV=Duty    
              Gosub DelayUs
         Next cycles
    
    Next Duty 
    
    DelayV=1000
    Gosub DelayUs
    
    ;sequence 0 (t = 1)
    ;=================
    For Duty = 2000 to 0 step -1 'ALL ON--> ALL OFF
         For cycles = 0 to Cycle1 
              Portb = %11110000 
              DelayV=Duty          
              Gosub DelayUs
              Portb = %00100000
              DelayV=2000-Duty    
              Gosub DelayUs
         Next cycles
    Next Duty 
    
    DelayV=1000
    Gosub DelayUs
    
    Goto Loop
    
    
    
    ;I will assume the minimum uSec pause is 4 (3 by the book)
    
    DelayUs:
         DelayV=DelayV/4
         while DelayV !=0
              Pauseus 4
              If switch then 
                   gosub StopEverything    
              ENDIF
              DelayV=DelayV-1
         WEND
         return
    
    StopEverything:
         While switch  ;wait untill switch is release
         Wend
         PAUSE 100 ; cheap debounce time
    
         While switch=0 ;wait for switch press
         Wend
         return
    what about now srig ?

    regards
    Last edited by mister_e; - 5th November 2004 at 01:22.
    Steve

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

Similar Threads

  1. Data Programming Error at 0000
    By cpatnoi in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd May 2009, 04:37
  2. Problems programming
    By Lionheart in forum General
    Replies: 4
    Last Post: - 7th December 2008, 17:51
  3. Who can help me checking my Programming
    By slimpeng in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 23rd January 2008, 16:08
  4. PIC programming algorithm - where is it to find?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th June 2007, 19:31
  5. MELab Programming
    By tarr in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd March 2006, 14:36

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