Multiplexer address control..


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Multiplexer address control..

    I didn't know we were going for speed....
    Dave Purola,
    N8NTA
    EN82fn

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: Multiplexer address control..

    or even this way, constant speed

    Code:
    control        EQU  0x30
    latb_shadow    EQU  0x31
    LATCH          EQU  0x32   ; simulate lat reg
     
    
     ORG     ResetVector
     goto    Start
    
    
    Start
      MOVLW 0
      MOVWF control
      MOVLW 3
      MOVWF LATCH ; eg. LATB,A
    lopo
      BANKSEL latb_shadow
      INCF control,F
      MOVLW 0xf
      ANDWF control,F
      
      MOVFF LATCH ,latb_shadow 
      MOVLW 0xf
      andwf latb_shadow ,F  
      SWAPF latb_shadow,F 
      MOVF  control,W
      IORWF latb_shadow ,F
      SWAPF latb_shadow,W
      MOVWF LATCH 
     
      GOTO lopo
    
      END
    Warning I'm not a teacher

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Post Re: Multiplexer address control..

    A little more thought reduces it further,no need at all for a shadow working reg at all
    works perfectly on the simulator steps through all 16 "control" states on latb 4-7 and preserves latb 0-3.

    Code:
    ; TODO INSERT CONFIG CODE HERE USING CONFIG BITS GENERATOR
      Processor      18f4550
     
      
      include         "p18f4550.inc"   
    TRUE  equ 1
    FALSE  equ 0
     cblock 0x30 
    control     
    ;latb_shadow   
     endc    
     
     
    RES_VECT  CODE    0x0000            ; processor reset vector
        GOTO    START                   ; go to beginning of program
    ; TODO ADD INTERRUPTS HERE IF USED
    MAIN_PROG CODE                      ; let linker place main program
    START
       
    
     
    
    
    
      MOVLW 0f
      MOVWF control
      MOVLW 3
      MOVWF  LATB,A
    lopo
      BANKSEL control
      INCF control,F
      MOVLW 0xf
      ANDWF control,F
      
      
      MOVF LATB,A,W
      ANDLW 0XF
      SWAPF WREG,F
      IORWF control,W
      SWAPF WREG,F
      MOVWF LATB ,A
     
      GOTO lopo
    Last edited by richard; - 24th July 2018 at 08:02.
    Warning I'm not a teacher

  4. #4
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: Multiplexer address control..

    if I may...

    Code:
    RES_VECT  CODE    0x0000            ; processor reset vector
        GOTO    START                   ; go to beginning of program
    ; TODO ADD INTERRUPTS HERE IF USED
    MAIN_PROG CODE                      ; let linker place main program
    START
     
    
            MOVLW   0f
            MOVWF   control
            MOVLW   3
            MOVWF   LATB,A
    lopo
            BANKSEL control
            incf    control,F       ; control = control + 1
            bcf     control,4       ; control = control mod 15
      
            swapf   control,W       ; B7..B4 <- control
            xorwf   LATB,W          ; wreg = differences
            andlw   0xF0            ; ignore B3..B0 bits
            xorwf   LATB,F          ; update B7..B4 bits
     
            GOTO    lopo

  5. #5
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: Multiplexer address control..

    t'would be simpler/faster still if you were to use the B3..B0 pins as both the 'control' variable and 'control' I/O;

    Code:
    RES_VECT  CODE    0x0000            ; processor reset vector
        GOTO    START                   ; go to beginning of program
    ; TODO ADD INTERRUPTS HERE IF USED
    MAIN_PROG CODE                      ; let linker place main program
    START
     
    
            movlw   0x30            ; B7..B4 other I/O, B3..B0 = control
            movwf   LATB            ;
    lopo
            incf    LATB,W          ; B3..B0 bits = control, 0..15
            xorwf   LATB,W          ; wreg = differences
            andlw   0x0F            ; ignore B7..B4 bits (and control mod 16 for free)
            xorwf   LATB,F          ; update B3..B0 bits, 0..15
     
            GOTO    lopo
    Last edited by Mike, K8LH; - 24th July 2018 at 23:08.

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: Multiplexer address control..

    if I may...
    Mike, K8LH
    that's exactly what a good forum needs

    your solution is excellent
    Warning I'm not a teacher

  7. #7
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default Re: Multiplexer address control..

    I like pedja089's solution which is probably about as simple, efficient, and elegant as you can get with pure PBP code. He might test clearing the four LATB bits and then setting them based on if control.0 = 1 then latb.4 = 1 (or something similar).

    I have to say the code PBP generated for the "Control << 4" instruction was pretty dismal. I'm curious to see what XC8 will generate for that...
    Last edited by Mike, K8LH; - 25th July 2018 at 04:13.

Similar Threads

  1. Replies: 5
    Last Post: - 21st January 2014, 16:10
  2. How do I give a radio control car autonomous control
    By Kenjones1935 in forum General
    Replies: 190
    Last Post: - 17th January 2010, 15:40
  3. Multiplexer channel selection
    By Castor in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 19th May 2008, 10:51
  4. Using a MAX7219 (LED digit multiplexer) with a 16F88
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th March 2007, 21:11

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