Shop OBEX P1 Docs P2 Docs Learn Events
Addpins - I don't understand — Parallax Forums

Addpins - I don't understand

pik33pik33 Posts: 2,366
edited 2022-06-05 09:50 in Propeller 2

I am experimenting with vga output. This works:

driver          setxfrq ##$2BAF66BA
                debug(uhex(pa))

                cogid   pa                      'insert cogid into dac modes
                setnib  dacmode_s,pa,#2
                setnib  dacmode_c,pa,#2

                rdlong  av_base_pin,ptra[5]     'get av_base

                wrpin   dacmode_s,av_base_pin  
                drvh    av_base_pin    
                add     av_base_pin,#1

                wrpin   dacmode_c,av_base_pin 
                drvh    av_base_pin 
                add     av_base_pin,#1

                wrpin   dacmode_c,av_base_pin 
                drvh    av_base_pin
                add     av_base_pin,#1

                wrpin   dacmode_c,av_base_pin 
                drvh    av_base_pin
                add     av_base_pin,#1               

                drvh    av_base_pin  

Now, instead of setting 3 pins pin by pin, I tried addpins

driver          setxfrq ##$2BAF66BA
                debug(uhex(pa))

                cogid   pa                      'insert cogid into dac modes
                setnib  dacmode_s,pa,#2
                setnib  dacmode_c,pa,#2

                rdlong  av_base_pin,ptra[5]     'get av_base

                wrpin   dacmode_s,av_base_pin  
                drvh    av_base_pin    
                add     av_base_pin,#1

                wrpin   dacmode_c,av_base_pin addpins 2
                drvh    av_base_pin addpins 2
                add     av_base_pin,#3

                drvh    av_base_pin  

This doesn't work. Also the Propeller Plug red led is lit, the serial terminal goes mad (debug is disabled) and I cannot understand what I am doing wrong here. av_base_pin=8

Edit: after I removed all not necessary things from the code (posted below) the Propeller Plug doesn't go mad but the screen is still black if addpins used.

Comments

  • pik33pik33 Posts: 2,366

    The full code simplified as much as I could. If it works, it displays green vertical strips. If addpins used, the screen is black.

    CON
      _clkfreq=  336956522 
    
      cols          = 240
      rows          = 1080
    
    VAR     cog    
    
    pub test
    start()
    
    PUB start() : cog
    cog := coginit(16, @driver, 0)
    
    ' Driver
    '
    DAT             org
    
    driver          setxfrq ##$2BAF66BA
    
                    cogid   pa                      'insert cogid into dac modes
                    setnib  dacmode_s,pa,#2
                    setnib  dacmode_c,pa,#2
    
                    wrpin   dacmode_s,av_base_pin  
                    drvh    av_base_pin    
                    add     av_base_pin,#1
    
                    wrpin   dacmode_c,av_base_pin 
                    drvh    av_base_pin 
                    add     av_base_pin,#1
    
                    wrpin   dacmode_c,av_base_pin 
                    drvh    av_base_pin
                    add     av_base_pin,#1
    
                    wrpin   dacmode_c,av_base_pin 
                    drvh    av_base_pin
                    add     av_base_pin,#1               
    
                    drvh    av_base_pin  
    ' Field loop
    '
    .field          mov     rowx,#0
    
    
    .line           xcont   m_bv,#0                 'do before-visible part of scan line
                    mov     aa,#240
    
                    rep     @.chr,#cols             'ready to output 8 pixels for each chr
                    mov     bb,aa
                    and     bb,#$F0
                    shl     bb,#16
                    xcont   m_px,bb
                    add     aa,#1                   '2 =15  output 8 single-bit pixels to streamer
    .chr
                    xcont   m_bs,#0                 'do before-sync part of scan line
                    xzero   m_sn,#$FF               'do sync part of scan line
    
                    incmod  rowx,##rows-1    wz
            if_nz   jmp     #.line                  'loop until all rows output
    
    
                    callpa  #3,#blanks             'do bottom blanks
                    drvnot  av_base_pin             'vertical sync on
                    callpa  #5,#blanks              'do vertical sync blanks
                    drvnot  av_base_pin             'vertical sync off
                    callpa  #18,#blanks           'do top blanks
                    jmp     #.field                'loop
    '
    '
    ' Output blank lines
    '
    blanks          xcont   m_bv,#0                 'do before-visible part of scan line
                    xcont   m_vi,#0                 'do visible part of scan line (blank)
                    xcont   m_bs,#0                 'do before-sync part of scan line
                    xzero   m_sn,#$FF                 'do sync part of scan line
            _ret_   djnz    pa,#blanks              'loop if more blanks needed
    '
    '
    ' Initialized data
    '
    dacmode_s       long    %0000_0000_000_1011000000000_01_00000_0         'hsync is 123-ohm, 3.3V
    dacmode_c       long    %0000_0000_000_1011100000000_01_00000_0         'R/G/B are 75-ohm, 2.0V
    
    m_bs            long    $7F010000+18            'before sync
    m_sn            long    $7F010000+32            'sync
    m_bv            long    $7F010000+110           'before visible
    m_vi            long    $7F010000+1920          'visible
    m_px            long    $7F010000+8             
    
    rowx            long    0
    font_base       long    0
    font_line       long    0
    '
    aa              long 0
    bb              long 0
    
    av_base_pin     long 8
    
  • evanhevanh Posts: 15,915
    edited 2022-06-05 09:59

    Hehe, not hard to make that mistake. The addpins should be applied to the data contained at av_base_pin. Ie: 8 addpins 2

  • pik33pik33 Posts: 2,366

    Oops... it applied addpins to the address and not to the value... Either more coffee or more rest needed.

Sign In or Register to comment.