Go Down

Topic: TVout: NTSC and PAL Composite Video Output. (Read 13 times) previous topic - next topic


@mdmetzle, Thanks!

I am looking for a way to get the tvout lib to let one pin go HIGH when there is a white pixel, and another pin go HIGH when there is a black pixel..

it should probably be done close to here, but i don't understand this..:

__asm__ __volatile__ (
   "ADD   r26,r28\n\t"
   "ADC   r27,r29\n\t"
   //save PORTB
   "IN      r16,%[port]\n\t"
   "ANDI   r16,0xFD\n\t"
(the above is from version 3 of the tvout lib, video_gen.ccp).

The first two lines are a 16bit add and are calculating the pointer to the current render line in the frame buffer.  The second 2 lines grab the port containing the output pin and set it to the video pin to low and the sync pin(if applicable in later versions) high.  Then through out the rest of the line rendering routine the video pin is modified and the rest of the port is left alone.  If you dont care about the port status then the these lines are not needed.


A couple of days ago I tried to realize a little idea of mine...
I used 2 standalone Atmega328 on a breadboard: the first one runs a sketch that uses the PS2Keyboard lib to read the input from a PS2 keyboard, the second one has a sketch inside che reads the input from the first Atmega and then sends the output on the TV.

But I'm having a strange problem: keys that I see on the TV are different from the ones I press on the keyboard.... I.E. I get [ESC] from "h" or "3[ESC]" from "7" etc...

Strange because if I connect the first Atmega to an Arduino and send the keys I read from the keyboard to a serial terminal open under the Arduino IDE I can see the correct keys (i.e. if I digit "h"-"e"-"l-"l"-"o" I see "hello"), so I can say for sure that the connection of the keyboard is OK. It seems that "pollserial" doesn't read the correct datas.

I connected the 2 Atmega using pins 2 and 3 (RX & TX): of course, 2->3 and 3->2.
This is the sketch on the first Atmega:
Code: [Select]
/*  PS2Keyboard library example*/
#include <PS2Keyboard.h>

const int DataPin = 2;
const int IRQpin =  3;

PS2Keyboard keyboard;

void setup() {
  keyboard.begin(DataPin, IRQpin);

void loop() {
  if (keyboard.available()) {
    // read the next key
    char c = keyboard.read();
    // check for some of the special keys
    if (c == PS2_ENTER) {
    } else if (c == PS2_TAB) {
    } else if (c == PS2_ESC) {
    } else if (c == PS2_PAGEDOWN) {
    } else if (c == PS2_PAGEUP) {
    } else if (c == PS2_LEFTARROW) {
    } else if (c == PS2_RIGHTARROW) {
    } else if (c == PS2_UPARROW) {
    } else if (c == PS2_DOWNARROW) {
    } else if (c == PS2_DELETE) {
    } else {
      // otherwise, just print all normal characters

This is the sketch that is running on the second Atmega:
Code: [Select]
#include <TVout.h>
#include <pollserial.h>
#include <fontALL.h>

TVout TV;
pollserial pserial;

void setup()  {
  TV.println("Terminale seriale");
  TV.println("-- Versione 0.1 --");

void loop() {
  if (pserial.available()) {


Is life really that serious...??!


What do you mean?
That I don't have to use common grounds or that I have to use them?  :smiley-roll-sweat:


Does the tvout sketch work when you send data from the pc?

Go Up