Help with assemblercode in Closed Caption

Store Forums Video Experimenter General Discussion Help with assemblercode in Closed Caption

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #416
    muerzi
    Member

    Hello!

    I’m developing an opensource videomodem (http://www.rcgroups.com/forums/showthread.php?t=1672628) for use in FPV (cam in a RC-Plane and live downstream). This device waits until line 21 or so appears and shifts (on 500kHz SPI-frquenzy) on “MOSI” 3Bytes out (Clock run-in will be replaced with a byte). I build the device same like Dennis Fries DIYOSD here (http://www.rcgroups.com/forums/showthread.php?t=1473207).

    Now my problem is how to extract the data out of the videostream on my groundstation.
    I ordered a video experimenter board that i’ll arive in about 2 weeks.

    Read the post about Closed Captioning (and studied the code), but i’m not familiar with assembler. Could it be possible that anybody comments the code and explain me whats going on there? Is it possible to change the code that it could read in the bits faster (1MHz, 2MHz, 4Mhz, 8MHz or 16MHz)? Whats the max speed?


    void capture_line5c() {
    __asm__ __volatile__ (
    "ADD r26,r28nt"
    "ADC r27,r29nt"
    "rjmp entercapture5n"
    "loopcapture5:nt"
    "in __tmp_reg__,%[acsr]nt" //8
    "bst __tmp_reg__,5nt"
    "bld r16,0nt"
    "st X+,r16nt"
    "entercapture5:nt"
    "in __tmp_reg__,%[acsr]nt" //1
    "bst __tmp_reg__,5nt"
    "bld r16,7nt"
    "delay2nt"
    "in __tmp_reg__,%[acsr]nt" //2
    "bst __tmp_reg__,5nt"
    "bld r16,6nt"
    "delay2nt"
    "in __tmp_reg__,%[acsr]nt" //3
    "bst __tmp_reg__,5nt"
    "bld r16,5nt"
    "delay2nt"
    "in __tmp_reg__,%[acsr]nt" //4
    "bst __tmp_reg__,5nt"
    "bld r16,4nt"
    "delay2nt"
    "in __tmp_reg__,%[acsr]nt" //5
    "bst __tmp_reg__,5nt"
    "bld r16,3nt"
    "delay2nt"
    "in __tmp_reg__,%[acsr]nt" //6
    "bst __tmp_reg__,5nt"
    "bld r16,2nt"
    "delay1nt"
    "dec %[hres]nt"
    "in __tmp_reg__,%[acsr]nt" //7
    "bst __tmp_reg__,5nt"
    "bld r16,1nt"
    "brne loopcapture5nt"
    "delay1nt"
    "in __tmp_reg__,%[acsr]nt" //8
    "bst __tmp_reg__,5nt"
    "bld r16,0nt"
    "st X,r16nt"
    :
    : [acsr] "i" (_SFR_IO_ADDR(ACSR)),
    "x" (display.screen),
    "y" (renderLine),
    [hres] "d" (display.hres)
    : "r16" // try to remove this clobber later...
    );
    }

    nice regards
    muerzi

    #950
    Michael
    Keymaster

    The assembler for capturing image data is very carefully crafted to be timed exactly. The approach is to read the analog comparator value to determine if a pixel should be “on” or “off”. This loop represents the capture of 8 bits (8 pixels), then it repeats until the screen is done.

    For each pixel the code is something like this. I’ve included more comments


    "in __tmp_reg__,%[acsr]nt" //2 -- this is the 2nd bit of the byte we are capturing. Read the ASCR register into __tmp_reg__
    "bst __tmp_reg__,5nt" // store the 5th bit of this value into T. 5th bit is analog comparator val
    "bld r16,6nt" // load T into the 6th bit of r16. r16 is the byte that holds the captured bits
    "delay2nt" // delay 2 cycles for perfect timing

    Study the AVR assembly guide and you’ll understand each instruction:
    http://www.atmel.com/Images/doc1022.pdf

    No, this can’t be sped up! This is written in assembly so we can do it as fast as possible. There isn’t even a spare cycle to be had. That’s why you can only do LOW resolution with the TVout library — the processor can’t run fast enough to capture or output pixels at the same rate as the TV scan rate.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.