Pages: [1]   Go Down
Author Topic: MAX7456 On screen display - getting started  (Read 380 times)
0 Members and 1 Guest are viewing this topic.
Lake District, UK
Offline Offline
Jr. Member
**
Karma: 0
Posts: 71
Electronics needs smoke to work, if it escapes its broken
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im trying to build an on screen display, its based on this thread
http://arduino.cc/forum/index.php/topic,8785.0.html

I have been messing around trying various sketches to get somthing to work with no luck
i decide to go back to basics and then hit a brickwall.
 Here is the code (its not mine all credit to its author etc)

Code:
#include <EEPROM.h> //Needed to access eeprom read/write functions

#define DATAOUT 11//MOSI
#define DATAIN  12//MISO
#define SPICLOCK  13//sck
#define MAX7456SELECT 10//ss
#define VSYNC 2// INT0

//MAX7456 opcodes
#define DMM_reg   0x04
#define DMAH_reg  0x05
#define DMAL_reg  0x06
#define DMDI_reg  0x07
#define VM0_reg   0x00
#define VM1_reg   0x01

//MAX7456 commands
#define CLEAR_display 0x04
#define CLEAR_display_vert 0x06
#define END_string 0xff
// with NTSC
#define ENABLE_display 0x08
#define ENABLE_display_vert 0x0c
#define MAX7456_reset 0x02
#define DISABLE_display 0x00

// with PAL
// all VM0_reg commands need bit 6 set
//#define ENABLE_display 0x48
//#define ENABLE_display_vert 0x4c
//#define MAX7456_reset 0x42
//#define DISABLE_display 0x40

#define WHITE_level_80 0x03
#define WHITE_level_90 0x02
#define WHITE_level_100 0x01
#define WHITE_level_120 0x00

// with NTSC
#define MAX_screen_size 390
#define MAX_screen_rows 13

// with PAL
//#define MAX_screen_size 480
//#define MAX_screen_rows 16

#define EEPROM_address_hi 510
#define EEPROM_address_low 511
#define EEPROM_sig_hi 'e'
#define EEPROM_sig_low 's'

volatile byte screen_buffer[MAX_screen_size];

volatile byte writeOK;
volatile byte valid_string;
volatile byte save_screen;
volatile int  incomingByte;
volatile int  count;

//
//##############################
//# 30 characters per line     #
//# 13 lines per screen        #
//# start'[' end ']' 390 chars #
//# add '~' if front of '[' to #
//# force write to eeprom      #
//# '~[]' to zero out eeprom   #
//##############################
//
//[
//
//
//       THIS IS A TEST
//
//    Arduino / MAX7456-OSD
//
//  ABCDEFGHIJKLMNOPQRSTUVWXYZ
//         0123456789
//]
//

//////////////////////////////////////////////////////////////
void setup()
{
  byte spi_junk, eeprom_junk;
  int x;
  Serial.begin(9600);
  Serial.flush();

  pinMode(MAX7456SELECT,OUTPUT);
  digitalWrite(MAX7456SELECT,HIGH); //disable device

  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(VSYNC, INPUT);

  // SPCR = 01010000
  //interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
  //sample on leading edge of clk,system clock/4 rate (4 meg)
  SPCR = (1<<SPE)|(1<<MSTR);
  spi_junk=SPSR;
  spi_junk=SPDR;
  delay(250);

  // force soft reset on Max7456
  digitalWrite(MAX7456SELECT,LOW);
  spi_transfer(VM0_reg);
  spi_transfer(MAX7456_reset);
  digitalWrite(MAX7456SELECT,HIGH);
  delay(500);

  // set all rows to same charactor white level, 90%
  digitalWrite(MAX7456SELECT,LOW);
  for (x = 0; x < MAX_screen_rows; x++)
  {
    spi_transfer(x + 0x10);
    spi_transfer(WHITE_level_90);
  }

  // make sure the Max7456 is enabled
  spi_transfer(VM0_reg);
  spi_transfer(ENABLE_display);
  digitalWrite(MAX7456SELECT,HIGH);


  // clear the array
  for (x = 0; x < MAX_screen_size; x++)
  {
    screen_buffer[x] = 0x00;
  }

  writeOK = false;
  valid_string = false;
  save_screen = false;
  incomingByte = 0;
  count = 0;

 // check to see if we have a default screen stored in eeprom
  eeprom_junk = EEPROM.read(EEPROM_address_hi);
  if (eeprom_junk == EEPROM_sig_hi)
  {
    eeprom_junk = EEPROM.read(EEPROM_address_low);
    if (eeprom_junk == EEPROM_sig_low)
    {
      for (x = 0; x < MAX_screen_size; x++)
      {
        screen_buffer[x] = EEPROM.read(x);
      }
      writeOK = true;
      count = MAX_screen_size;
    }
  }

  Serial.println("Ready for text file download");
  Serial.println("");
  delay(100); 
}

I get this error

sketch_mar24a:57: error: 'spi_transfer' was not declared in this scope

i figured the SPI.h needed to be included so i added it to the code
still same error.
i suspect this has something to do with the IDE version im using - still on Arduino IDE Ver 1.0.1
but i have tried the code on Ver 1.5 and the old Ver 22.

please help
sketch_mar24a:57: error: 'spi_transfer' was not declared in this scope
Logged

Gloucester
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

have a look at this site. Its in French.
http://f5mna.free.fr/Arduino.htm
Yours Simon M.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey buddy
Did you managed to get your osd working?
Trying to get mine to work using the same code and no luck so far
Logged

Pages: [1]   Go Up
Jump to: