Speed optimization (framebuffer scrolling)


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,651


    Did you find this post helpful? Yes | No

    Default Re: Speed optimization (framebuffer scrolling)

    18f26k22

    i have not tried much with Q43 yet , but
    they have no ram below bank 5.
    i dont know what bank pbp defaults to for them bank0 makes no sense at all , before them pbp kinda assumes bank0 before and after calls.
    the instruction set is slightly different. movfffl or whatever
    there may be other weird shit with indirect addressing

    i have some q43's i just lack the enthusiasm to learn about them when the tried and trusty k22 serves my needs
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Speed optimization (framebuffer scrolling)

    try them in bank6
    and just remove the banksel 0 at the end


    i added a rotate left to and a few tweaks

    Code:
    '****************************************************************'*  Name    : UNTITLED.BAS                                      *
    '*  Author  : richard                                           *
    '*  Notice  : Copyright (c) 2022 caveat emptor                  *
    '*          : All Rights Reserved                               *
    '*  Date    : 11/10/2022                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          : pic18f26k22                                                  *
    '****************************************************************
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = ON
      CONFIG  PRICLKEN = ON
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = ON
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = OFF
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5
      CONFIG  T3CMX = PORTC0
      CONFIG  HFOFST = ON
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
        
    
    
        NumberOfDisplays  CON 36
        NumberOfRows  CON 10
        DEFINE OSC 64
        DEFINE DEBUG_REG PORTB
        DEFINE DEBUG_BIT 7
        DEFINE DEBUG_BAUD 9600
        DEFINE DEBUG_MODE 0
        LATB.7=1
        bcnt       VAR BYTE   bank0
        dcnt       VAR BYTE   bank0
        BUFF       VAR BYTE[32]
        iteration  VAR word 
        OSCCON=$70
        OSCTUNE.6=1
        while ! osccon2.7 :WEND    ;wait for pll
        ANSELB=0
        ANSELC=0
        ANSELA=0 
        dspbuff var byte[380]
        clear
        trisc = %01111111 
        TRISB = %01111111
        TRISA = %11111111
        pause 1000
        debug 13,10,"ready",13,10
        LATc.7=0
        ;38x8 bits wide 10 bits high
    
    
    main:
        iteration=0
        dspbuff[379]=3
        dspbuff[37]=3
        WHILE  iteration<610
            LATc.7=1
            gosub rotate_l
            LATc.7=0
            debug 13,10,dec iteration
            debug 13,10,bin8 dspbuff[379]," " ,bin8 dspbuff[378]," " ,bin8 dspbuff[343] ," ",bin8 dspbuff[342] 
            debug 13,10,bin8 dspbuff[37] ," " ,bin8 dspbuff[36] ," " ,bin8 dspbuff[1]   ," ",bin8 dspbuff[0] 
            pause 50
            iteration=iteration+1 
        WEND
        iteration=0
        dspbuff[379]=$c0
        dspbuff[37]=$c0
        WHILE  iteration<610
            LATc.7=1
            gosub rotate_R
            LATc.7=0
            debug 13,10,dec iteration
            debug 13,10,bin8 dspbuff[379]," " ,bin8 dspbuff[378]," " ,bin8 dspbuff[343] ," ",bin8 dspbuff[342] 
            debug 13,10,bin8 dspbuff[37] ," " ,bin8 dspbuff[36] ," " ,bin8 dspbuff[1]   ," ",bin8 dspbuff[0] 
            pause 50
            iteration=iteration+1 
        WEND
    goto main    
        
        
        
        
    rotate_r:  ' pic18
    asm
        banksel _bcnt  ;ROW
        movlw   _NumberOfRows    ;10 rows  
        movwf   _bcnt
        movlw   high (_dspbuff)  ;BOTTOM OF BUFFER
        movwf   FSR0H    
        movlw   low  (_dspbuff)
        movwf   FSR0L
        movlw   low((_NumberOfDisplays + 2)*_NumberOfRows-1) ;TOP OF BUFFER
        ADDWF   FSR0L 
        movlw   high((_NumberOfDisplays + 2)*_NumberOfRows-1)    
        ADDWFC  FSR0H
        MOVLW   _NumberOfDisplays + 2;36 displays + 2 outside of display 
    RROW  
        movwf   _dcnt        ;display
        bcf     STATUS, C
    Rcol
        rrcf    POSTDEC0 ,f  ;PER display
        DECFSZ  _dcnt ,F
        BRA     Rcol
        BNC     RBNC
        bsf     PLUSW0,7     ;max displays would be 127 to use plusw
    RBNC 
        DECFSZ  _bcnt ,F
        BRA     RROW
        banksel 0
        return
    endasm
     rotate_l:  ' pic18
    asm
        banksel _bcnt              ;ROW
        movlw   _NumberOfRows 
        movwf   _bcnt
        movlw   high (_dspbuff)    ;BOTTOM OF BUFFER
        movwf   FSR0H    
        movlw   low  (_dspbuff)
        movwf   FSR0L
    LROW
        MOVLW   _NumberOfDisplays + 2;36 displays + 2 outside of display 
        movwf   _dcnt         ;display
        comf    WREG
        incf    WREG
        bcf     STATUS, C
    Lcol
        rlcf    POSTINC0 ,f   ;PER display
        DECFSZ  _dcnt ,F
        BRA     Lcol
        BNC     LBNC
        bsf     PLUSW0,0       ;max displays would be 127 to use plusw
    LBNC 
        DECFSZ  _bcnt ,F
        BRA     LROW
        banksel 0
        return
    endasm
    Warning I'm not a teacher

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


    Did you find this post helpful? Yes | No

    Default Re: Speed optimization (framebuffer scrolling)

    with my suggestions it compiles for 18f47q43, whether it works is not tested . a quick browse of the q43 instruction set and access bank looks ok
    Warning I'm not a teacher

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Speed optimization (framebuffer scrolling)

    Bank 6 (or 7) doesn't work at all. I don't know what it's doing exactly. It does display the text but it does not scroll it.

    Bank 5 (or 25) works - sort of.
    I can scroll it left OR right continously without issues but when I change direction whatever is in the non visible part the buffer comes back on to the display shifted down by one row - at least I think that's what happening.

    But it's fast, that's for sure.
    * Mine was like 7ms or something like that
    * tumblweeds was more than twice as fast at 3ms.
    * Richards comes in at 0.2ms - amazing.

    Mine and tumbleweeds simply scrolls the display, anything that's shifted outside of the buffer is lost while Richards rotates it so they're not exactly the same.

    /Henrik.

  5. #5
    Join Date
    Aug 2011
    Posts
    455


    Did you find this post helpful? Yes | No

    Default Re: Speed optimization (framebuffer scrolling)

    On most of the Q family the SFR registers are in banks 0-4, and the start of user ram is in bank 5.
    That's where the access bank is (0x500-0x55F). The other part of the access bank is at 0x460-0x4FF, but that's for the fast SFR registers so you can't use that.
    So, the "default" setting for 'banksel' should be 5 and not 0.

    If you use the MOVFF instruction both the source and destination must be in the first 4K of ram space.
    If either are outside that you need to use MOVFFL, which is a three-word instruction so it's more code (and slower) than MOVFF.

    The K42/K83 force you to use MOVFFL to access SFR registers outside the access bank since on those the SFR regs are at the very top of ram.
    That's one reason to skip the K42 and use the Q43 instead.

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


    Did you find this post helpful? Yes | No

    Default Re: Speed optimization (framebuffer scrolling)

    I can scroll it left OR right continously without issues but when I change direction whatever is in the non visible part the buffer comes back on to the display shifted down by one row - at least I think that's what happening.
    i expected to have had the buffer cleared out and reset before a direction change . however that sort of behavior is unanticipated



    * Richards comes in at 0.2ms - amazing.
    i get 0.1mS , maybe my oscilloscope is off



    one of my clients sent me a test jig for q43 chips yesterday. i need to get into them soon i guess
    no more excuses

    @tumbleweed for confirming what i thought
    Warning I'm not a teacher

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,651


    Did you find this post helpful? Yes | No

    Default Re: Speed optimization (framebuffer scrolling)

    just for interest i tried my code on the st7920 buffer for rows 8 to 15 for the full 16 byte width of course



    works as expected even when direction reversed midstream
    Attached Files Attached Files
    Warning I'm not a teacher

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,651


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Speed optimization (framebuffer scrolling)

    or a window to scroll
    [i just can't help myself]
    Warning I'm not a teacher

Similar Threads

  1. Re:Scrolling speed control problem in moving message display
    By machobob in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 19th June 2010, 12:08
  2. Replies: 0
    Last Post: - 7th August 2008, 09:02
  3. code size VS speed optimization setting?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2008, 14:38
  4. While we're on the subject of optimization...
    By skimask in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 11th March 2008, 12:51
  5. Multiple if then optimization
    By Mugelpower in forum mel PIC BASIC Pro
    Replies: 35
    Last Post: - 5th March 2008, 12:15

Members who have read this thread : 1

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