Go Down

Topic: Interfacing with an NTSC TV (Read 4 times) previous topic - next topic

binarymillenium

From a couple of experiments I don't think I can display much beyond 900 pixels- I'm pretty sure this is because I'm using a byte of memory per pixel and there's only a kilobyte of ram- maybe you have less?

But for the two shades of gray each byte of memory could be 4 different pixels, so if memory is the problem resolution should be able to go 4 times as high like this:
     PORTB = (fb
  • [y]) & 0x3;
         PORTB = (fb
  • [y] >> 2) & 0x03;
         PORTB = (fb
  • [y] >> 4) & 0x03;
         PORTB = (fb
  • [y] >> 6) & 0x03;    

    A for loop to draw the screen didn't work for me but I didn't play with timing with it much.

    delayMicroseconds of less than one microsecond also didn't work but I also didn't experiment much.
    Assuming you can get more horizontal pixels (or you could repeat the pattern horizontally) I think the best thing to do is just get rid of the delays, and the delay of setting PORTB is the limiting time for horizontal resolution- though I'm seeing some strange things doing that while trying to repeat horizontally- the second set of pixels comes out thinner.

xSmurf

Thanks for the video! that was great. Fixed the issue for real this time.

line 61 is now:
#define      _ntscDelayBackPorch            5.9
and line 64:
#define _ntscDelayVSync                  50

Now why can't I rev up the resolution?... basically anything over 21x16 seems to crash (I don't use the sprite with it, obviously!)
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

binarymillenium

#2
Aug 28, 2007, 05:33 am Last Edit: Aug 28, 2007, 04:04 pm by binarymillenium Reason: 1
The cli() command seems to work for me, though I have a brand new diecimilla i think with the 0009 (?) firmware.  I haven't seen any of the odd failures you mention.

From my experience the top lines are curved because of the length of your vsync too short and it curves one way and too long it curves the other way- I made a little video of the effect- http://vimeo.com/288344

xSmurf

#1
Aug 28, 2007, 02:32 am Last Edit: Aug 28, 2007, 07:17 pm by xSmurf Reason: 1
Hey guys, this is a follow up on this topic. It started in French, but I figured since NTSC is used mainly in America and in Japan, English might be better suited for the topic. The basic setup is the same as the Arduino pong and the other topic. So this is just my "port" of what these guys did. I did build mine with a "structure" to allow adding pal support to be able to switch modes easily in the code.

Disabling the interrupt timer

I haven't gotten my code to work with cli() and serial so you'll have to modify lib/target/arduino/wiring.c (MAKE A BACKUP) like such:
Code: [Select]

// enable timer 0 overflow interrupt
#if defined(__AVR_ATmega168__)
   sbi(TIMSK0, TOIE0);
#else
   sbi(TIMSK, TOIE0);
#endif


To:
Code: [Select]

/*
   // enable timer 0 overflow interrupt
#if defined(__AVR_ATmega168__)
   sbi(TIMSK0, TOIE0);
#else
   sbi(TIMSK, TOIE0);
#endif
*/


The circuit



That is... Sync to port 8 on the arduino and video to port 9. I use 900 and 300ohm resistors but it should change much anyway; these can be a little off.


Grab the latest version of the code.

Once you've uploaded the code, connect via serial (I use screen in the terminal) and wait for the uC to finish loading (you'll see "Mode:"). If everything went well there should be a dot in the middle of the TV. Now hit enter for usage. If you read through the code you will see there is a way of enabling "signal voltage mode" which allows you to debug your circuit.

There are a few things that are acting weird... I could really use some feedback.
  • If you put the resolution higher the uC seems to crash (not enough ram?).
  • Sometimes the uC acts as if the mode (output) had not been set properly. Re-uploading seemed to have fixed the problem when I've seen it.
  • There may be a timing issue while writing the first few lines. (EDIT: The issue has been fixed, see posts bellow)
  • Going into signal mode sometimes seems to crash the uC (same behavior as the first issue)


I've tested these this with both a mega8 and mega168 (thanks to the USBTiny that appeared in my mailbox this morning and a little magic from its fairy) on the NG and under 0007 and 0009. Optimally this code would need to be ported to a version with interrupt support.

P.S. If that pastie ever goes down, here is a plain text mirror.

And the obligatory picture ^-^


[size=10](The flickering at the top seems to have been fixed - at least as best as I could) FIXED[/size]
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Go Up