DCD command - need some advice


Results 1 to 21 of 21

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    how about this one?
    Code:
    ;************* set up pattern data **********
        
    Patt1 DATA 16,1,2,4,8,16,32,64,128,128,64,32,16,8,4,2,1 
    Patt2 DATA 8,129,66,36,24,24,36,66,129 
    Patt3 DATA 16,1,3,2,6,4,12,8,24,16,48,32,96,64,192,128,0 
    Patt4 DATA 16,1,128,2,64,4,32,8,16,8,32,4,64,2,128,1,0 
    Patt5 DATA 12,24,60,126,255,231,195,129,0,129,195,231,255 
    Patt6 DATA 13,1,2,4,8,17,34,68,136,16,32,64,128,0 
    Patt7 DATA 8,128,64,32,16,8,4,2,1
    
    ;************* set up PIC ********************
    
    ADCON1=$0F
    CMCON = 7                        ' Digital inputs
    CCP1CON = 0                      ' PWM off
    TRISA=%11100111                  'set PORTA as all input apart from A3 & A4
    TRISB=%00000000                  'set PORTB as all output
    PORTB=0
    
    ;************* set up variables ***************
    
    Patt    var byte [8]
    asm
        MOVE?CB _Patt1,_Patt+1 ; Patt[1]
        MOVE?CB _Patt2,_Patt+2 ; Patt[2]
        MOVE?CB _Patt3,_Patt+3 ; Patt[3]
        MOVE?CB _Patt4,_Patt+4 ; Patt[4]
        MOVE?CB _Patt5,_Patt+5 ; Patt[5]
        MOVE?CB _Patt6,_Patt+6 ; Patt[6]
        MOVE?CB _Patt7,_Patt+7 ; Patt[7]
    endasm
    
    ByteA   var byte
    D var byte
    scale var byte                      ;used in the POT command
    Scale = 254  
    steps var byte
    swcount var byte
    swcount=7                           ; set to 3 for testing only
    D=250
    ;**************** main program ********************
    main:
        for swcount=1 to 7
            read patt[swcount],steps
            for bytea=1 to steps
               READ PATT[SWCOUNT]+BYTEA,PORTB
               PAUSE D
               NEXT
            next
        GOTO MAIN
    noticed that i skiped the POT command but use a fixed 250mSec delay. It's working here. if you want to use DCD, you'll need to modify the DATA lines and use bit# instead of Decimal value. No big deal

    It shouldn't be different from one to another. DATA remain DATA. PORTB remain PORTB. Well i can't explain why if it doesn't create the expected results with the above suggestion

    Too bad, MPASM text substitution doesn't seems to work with Bytes variable in the #V(Variable) area.. it would be too convenient...

    EDIT: Note that MOVE?CB _Patt1,_Patt+1 can be replace by Patt[1]=Patt1 etc...

    The whole MOVE?CB block (or Patt[x]=Pattx) could also be replace using MPASM text substitution like this
    Code:
    asm
        local a=1
        while a<7
            MOVE?CB _Patt#v(a),_Patt+a
    a+=1
            endw
    endasm
    Last edited by mister_e; - 16th December 2006 at 18:08.
    Steve

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

Similar Threads

  1. Need "PIC16F84A" Controler schematic Advice...
    By Kyo_89 in forum Schematics
    Replies: 1
    Last Post: - 27th May 2009, 23:03
  2. Design Advice
    By isaac in forum General
    Replies: 38
    Last Post: - 11th October 2008, 23:07
  3. Your OTP advice?
    By truvahorse in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 28th June 2008, 16:37
  4. NCD vs. DCD - Commentary
    By andrewroz in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th November 2007, 23:16
  5. Advice needed on 'neat' Project!
    By vacpress in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th February 2007, 06:21

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