Shop OBEX P1 Docs P2 Docs Learn Events
NTSC Timing issues — Parallax Forums

NTSC Timing issues

YanirYanir Posts: 11
edited 2005-03-12 15:06 in General Discussion
Hi all, I posted a similar question earlier, thanks again to all who helped out, i am on the right track but I am running into another roadblock.

I wrote some code that is basically a DA converter that generates 3 voltage levels, 0v, .33v, and 1v. Those of you familiar with TV analog signals will know that 0v-1v is the range that the TV interprets as info.

Following some guides on timing protocols I seemingly am generating the correct signals. I wrote a subroutine that creates a delay of 1u and use that (along with a couple of NOP's) to create precise timing. I am taking all calls and jmps into account. I am only generating horizontal sync pulses right now, and my first goal to create a white screen. However I am creating two pairs of vertical lines composed of dots. The first in the pair is faint (i didnt' even notice it for a couple of hours) and the second is bright. The first pair in near the left edge of the TV and the second set is to the right of the center. They slide down the screen becuase I am not sending a vertical sync pattern.

My voltage is constant, I can't imagine why I would be getting this strange pattern.
Two thoughts:
1. When I step or walk through my code, it ocasionaly jmps to some random place in memory with no commands and never returns to the code (this seems to occur on the jmp to main.

2. I have my processor set at 50mhz, resulting in a 20ns cycle, are there other settings i need in place to ensure this performance?

Thanks again in advance

Yanir

Comments

  • BeanBean Posts: 8,129
    edited 2005-03-10 15:45
    Can you post your code ?

    Question 1: Sounds like your jumping to another code page.

    Question 2: Use TURBO in the DEVICE settings.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • YanirYanir Posts: 11
    edited 2005-03-10 15:55
    ok heres the code, thanks


    device··sx28l,oschs3
    device··turbo,stackx,optionx
    IRC_CAL··IRC_fast
    reset··Main
    freq··50_000_000·;50 mhz 50_000_000
    ··org··$08
    ;output··=·rb.0
    cycle_cnt··ds·1
    delay_cnt··ds·1
    set_cycle_cnt··ds·1


    org··$008
    Delay


    delay_loop·mov·cycle_cnt,#16 ;11····;loop for number of ms, specified in w
    micro_loop·djnz·cycle_cnt,micro_loop·;loop for 1027 ns = 1.027 ms
    ··ret
    org··$100
    Main
    init
    ··mov·!rb,#0
    ··clr·rb
    ·; for 4.7 ms send HSync 0v
    ··;cje·rc,%0,Flip
    ··;mov·w,#4
    main_loop·call·Delay····;1u
    ··call·Delay····;1u
    ··call·Delay····;1u
    ··call·Delay····;1u
    ··;34 nop's and setb for .7u
    ··nop·····;.02u
    ··nop·····;.02u
    ··nop·····;.02u
    ··nop·····;.02u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u··Yotal NOPs .68

    ··setb·rb.0····;.02u··;swapped
    ··;mov·w,#8· ; Back Porch 5.9u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.10u
    ··nop
    ··nop
    ··nop
    ··nop·····;.08u
    ··;nop

    ··setb·rb.1····;.02u
    ··;mov·w,#52 ; Visible Image 51.5

    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay
    ··call·Delay····;5u
    ··call·Delay····;1u
    ··;call·Delay
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.1
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.1
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.1
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.1
    ··nop
    ··nop
    ··nop
    ··nop·····;.08
    ··;nop
    ··clrb·rb.1····;.02
    ··;front porch 1.4u

    ··call·Delay····;1u

    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.1u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.1u
    ··nop
    ··nop
    ··nop
    ··nop
    ··nop·····;.1u
    ··nop·····;.02u
    ··clrb·rb.0····;.02u
    ··jmp·main_loop···;.06u
    END
    watch·delay_cnt,8,UDEC
    watch·cycle_cnt,8,UDEC
    watch·RB,8,SBIN
    watch·RC,8,SBIN
  • BeanBean Posts: 8,129
    edited 2005-03-10 16:02
    Yeah,
    Your code is running onto the next code page.
    Try using "call @delay" and "jmp @main_loop" remember the '@' will cause the instruction to take an extra cycle.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-10 16:06
    There are much more code compact ways of acheiving this, I have figured out the timing requirements using loop based delays. Ill share the code for the single color screen when I get home.
  • Jim McCorisonJim McCorison Posts: 359
    edited 2005-03-10 16:48
    Unless I misunderstand the issue at hand, this issue was just covered, albeit tangentially, in the thread http://forums.parallax.com/showthread.php?p=528797 wherein Gunther posted a link to a SX Delay Code Generator tool at techref.massmind.org/cgi-bin/delay.exe.

    Jim
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-03-10 17:34
    This may be helpful.

    I ported the SERVID program some years ago to be compiled with sasm.

    It contains a delay macro and runtime routine.

    I extracted that delay into delay.src

    It is used to generate NTSC/PAL timing pulses.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-03-10 17:42
    Here is my adapted port of servid to be used with a 50MHz resonator.

    regards peter
  • BeanBean Posts: 8,129
    edited 2005-03-10 18:03
    Wow, lots of good info in that file (servid2_sx.src). I wish I had that file a couple months ago.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • YanirYanir Posts: 11
    edited 2005-03-10 18:07
    Is it my delay function thats the problem? I know it's not the most efficient code, i just want to see what I expect on the screen before I streamline, I had another sub that took w as an input for the number of ms desired, but that was a little buggy, so i stopped using that for now.

    I tried the @ and that eliminated the faint dots, and I now have 3 vertical lines of dots, all seemingly equidistant.
    It doesn't run to another page now, thanks Bean.

    Why dots? Still puzzled.
    Thanks for all the great responses. Hope there are more to come.

    yanir
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-03-10 18:10
    Bean,

    The servid_sx·is listed on sxlist.com ever since I did that port.

    There is a link at the bottom on the servid page at sxlist.com

    http://www.sxlist.com/techref/ubicom/lib/io/dev/video/servid.htm

    regards peter
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-10 18:18
    Bean: You didn't thoroughly peruse Rickard Gunee's links? Its the 3rd link, which has an older version but has a link to the sourceforge page for the current version (which is up to servid4.zip now)

    Post Edited (Paul Baker) : 3/10/2005 6:27:41 PM GMT
  • MayfieldMayfield Posts: 5
    edited 2005-03-10 22:54
    You do know that there is a Half of a Horizontal line for·every Field?

    Thats 262.5 horizontal lines per field.

    This is part of the Interlace Smile that NTSC uses.

    The Horizontal and Vertical·Syncs have a close relationship.

    Most of the Sync decoder chips rely heavily on this.

    You might want to try to·do the Vertical·Timing at the same time.

    (a chicken and egg thing)

    Sync in NTSC can be very unforgiving.

    You might want to get that timing down to at least 0.2uS.

    1uS is really loose.

    And don't forget... When you decide to use color, the Horizontal becomes 15.734.25 Hz and Vertical·= 59.94 Hz.

    Tom M.
  • BeanBean Posts: 8,129
    edited 2005-03-11 00:13
    You don't HAVE to use interlaced video, you can just use 262 lines of non-interlaced video.

    Here is what lines my serial video module outputs.

    6 - VSYNC - Block sync for 6 lines (sync level all the time)
    40 - TopBlank - Top blank lines (5uSecs of sync, rest black)
    192 - Video - Active video lines (5uSecs of sync, 10uSecs left boarder, 41uSec active video, rest black)
    24 - BotBlank- Bottom blank lines (5uSecs of sync, rest black)

    each of these lines lasts for 65.6uSeconds (I know it's not exactly NTSC timing, but it's needed for serial comm).

    I have tried my module on close to a dozen different video inputs and it has worked on all of them.
    I'm not saying there may be some system that it won't work on, but NTSC is pretty forgiving.

    Edit: Forgot to mention that this is strictly "black and white" video output.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • James NewtonJames Newton Posts: 329
    edited 2005-03-11 01:02
    Lots of good stuff at

    http://www.sxlist.com/lib/io/dev/video

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    James Newton, Host of SXList.com
    james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
    SX FAQ / Code / Tutorials / Documentation:
    http://www.sxlist.com Pick faster!



  • BeanBean Posts: 8,129
    edited 2005-03-12 13:50
    For anyone that is interested, I have posted the schematic and source code for my video module on the website. If your interested in generating NTSC with the SX, take a look.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • YanirYanir Posts: 11
    edited 2005-03-12 15:06
    Thanks again for all those who helped, I fixed some bugs and hopefully things will be working soon.
    Yanir
Sign In or Register to comment.