Shop OBEX P1 Docs P2 Docs Learn Events
VGA text driver questions/concepts - Q's probably for Chip - vga streamer interrupts wkg - Page 2 — Parallax Forums

VGA text driver questions/concepts - Q's probably for Chip - vga streamer interrupts wkg

2»

Comments

  • There seems to be some small jitter and I can't lock onto the output signal perfectly with my LCD monitor each time I auto adjust and some pixels look a bit wider than others. Are you using fractional ratios of P2:pixel clocks or integer ratios? Fractional ratios could cause this issue.

  • cgraceycgracey Posts: 14,133

    @Cluso99 said:
    VGA using Interrupts
    Attached is VGA_640x480_text_80x40_interrupt which runs the streamer under interrupts

    I found a couple of traps

    • waitx does not work in the non-interrupt code - I presume we cannot interrupt a waitx instruction ?
    • don't use calls in the interrupt code - I expect/presume we only have one internal stack space

    ' setint1 #INT_XMT
    The INT_xxx definitions (as defined in the spin document 34r/s) appear not to work

    You can do CALLs within ISRs. There is as much stack space as was available before the interrupt.

    WAITX cannot be interrupted. Better to use loops for timing if interrupts are desired.

  • Cluso99Cluso99 Posts: 18,069
    edited 2021-02-16 05:30

    There's actually a section I missed inserting "resi1" into (4 places) :(

    OOPS - this breaks the code
    found it - it returns in a rep loop - another trap

    .line
            xcont   m_bv,#0         'do before-visible part of scan line
            resi1
    
            rdfast  #0,screen_base      'set fifo to read from current screen row
    
            rep @.chr,#cols     'ready to output 8 pixels for each chr
    
            rfbyte  pa      wc  '2  get chr
            bitc    m_px,#16        '2  select colors using msb of chr
            and pa,#$7F         '2  trim chr to 7 bits
            add pa,font_base        '2  add offset for top/middle/bottom lines of chr
            rdlut   pa,pa           '3  look up four lines of chr
            shr pa,font_line        '2  get line of interest into lower 8 bits
            xcont   m_px,pa         '2 =15  output 8 single-bit pixels to streamer
    '       resi1                                       <<<<<<<<<<<<< cannot do this within a rep loop!!!
    .chr
            xcont   m_bs,#0         'do before-sync part of scan line
            resi1
            xzero   m_sn,#1         'do sync part of scan line
            resi1
    
    

    I will update the code later

  • Cluso99Cluso99 Posts: 18,069

    @cgracey said:

    @Cluso99 said:
    VGA using Interrupts
    Attached is VGA_640x480_text_80x40_interrupt which runs the streamer under interrupts

    I found a couple of traps

    • waitx does not work in the non-interrupt code - I presume we cannot interrupt a waitx instruction ?
    • don't use calls in the interrupt code - I expect/presume we only have one internal stack space

    ' setint1 #INT_XMT
    The INT_xxx definitions (as defined in the spin document 34r/s) appear not to work

    You can do CALLs within ISRs. There is as much stack space as was available before the interrupt.

    WAITX cannot be interrupted. Better to use loops for timing if interrupts are desired.

    The places where calls would be dangerous is calling the blanks because you would return while still inside the call so the stack would likely get confused!!

  • Cluso99Cluso99 Posts: 18,069
    edited 2021-02-16 05:44

    @rogloh said:
    There seems to be some small jitter and I can't lock onto the output signal perfectly with my LCD monitor each time I auto adjust and some pixels look a bit wider than others. Are you using fractional ratios of P2:pixel clocks or integer ratios? Fractional ratios could cause this issue.

    Fractional

            rdlong  pa,#@clkfreq        'calculate streamer frequency
            qfrac   ##fpix,pa
            getqx   pa
            shr pa,#1
            setxfrq pa
    

    I'm just using 216MHz (optimal for 1280x1024) where 50MHz multiples are better for 640x48.
    Can you try with _clkfreq = 200_000_000 ?

    At 200MHz: I'm not seeing jitter on my LCD but I am seeing some wider pixels (consistent) on some of the characters. It's a little blurry too. I'm using an Acer 24" 1920x1080.

  • WAITX blocks interrupts.

    Try
    setint1 #EVENT_XMT

  • Yeah that looks cleaner with 200MHz setting Cluso.

  • Cluso99Cluso99 Posts: 18,069

    Thanks Roger. I think the wider character pixel rows are because of the scaling in my monitor.

    Thanks Brian. I'll try EVENT_XMT. Yes I realised why waitx cannot be interrupted but it's a trap because it's easily forgotten. Initially I just went gungho and changed the lot and of course nothing worked. Then I had to start again, implementing bits at a time and testing.

    I've realised the rep section is tight timing and so it's likely missing the interrupt and once that happens the whole process stops. I tried a loop before I realised this. But I think the ultimate may be to do the whole line and display it in one go instead of a character at a time.

  • Cluso99Cluso99 Posts: 18,069
    edited 2021-02-16 08:33

    Here is the code. VGA 640x480 text 80x40

    There's a few commented out sections.
    Tested on P2-EVAL and RetroBlade2
    Specify both VGA-Base (4 pins HBGR) and Vsync (VS) pins seperately
    Flashes LEDs on both pins 0 and 56

    Forgot to test this - it works so apply the change if you wish

            mov ijmp1,#field        'set up streamer-empty interrupt
    '       setint1 #10
            setint1 #EVENT_XMT
    
Sign In or Register to comment.