MODMAX7456

MODMAX7456 is an easy to use library that allows you to create a text overlay system on a PAL or NTSC video display.

Connecting up the MAX7456 chip

The MODMAX7456 library only requires you to connect the SPI signals MOSI, MISO abd SCLK to one of the two SPI interfaces on the MBED. Additionally, you also need to connect CS (chip select), RESET and the Vertical Sync signals from the MAX7456 to Mbed pins. CS and RESET need to connect to Mbed pins that can be DigitalOut types and the Vertical Sync must connect to an Mbed that supports InterruptIn.

Connecting the MAX7456

Using the MODMAX7456 library

First, import the library into the online compiler.

ยป Import this library into a programMODMAX7456

This module provides a simple API to the Maxim MAX7456 on-screen display chip

Once imported, change your projects main.cpp to:-

#define COMPILE_EXAMPLE_CODE_MODOSD7456
#define PCBAUD 115200
#define MAX7456_MOSI  p5
#define MAX7456_MISO  p6
#define MAX7456_SCLK  p7
#define MAX7456_CS    p8
#define MAX7456_RST   p20
#define MAX7456_VSYNC p15
#include "/MODMAX7456/example1.cpp"

The above uses Mbed pins used in initial testing. If you have connected up your MAX7456 device to different pins ensure you change the #defines to match the pins you used.

Now switch everything on. LED1 should begin slowly flashing. This just tells you that the example program is running. Assuming you have connected up video in and out of your MAX7456 device your display should now be showing some test messages.

Using the MOD7456 library

Before attempting to use the MAX7456 you should become familiar with the device datasheet. But before diving into that the library offers an "easy to use/getting started" class wrapper called OSD7456 (where OSD means On Screen Display). The example1.cpp program uses this as it's test. Here is example1.cpp to show how easy it is to get started:-

#include "mbed.h"
#include "OSD7456.h"

DigitalOut led1(LED1);

OSD7456 *osd;

int main() {
    
    osd = new OSD7456(MAX7456_MOSI, MAX7456_MISO, MAX7456_SCLK, MAX7456_CS, MAX7456_RST, MAX7456_VSYNC);
    
    // Set the character "local background" to 42%
    osd->max7456->backGround(MAX7456::Percent_42);
    
    // Set the blink rate to 133ms with a duty cycle of 3:1
    osd->max7456->blinkRate(MAX7456::ms_133, MAX7456::BT3_BT);
    
    osd->print(1, "        Hello World");
    osd->print(7, 4,  "Positioned text");
    osd->print(7, 6,  "Positioned text", MAX7456::LocalBG);
    osd->print(3, 8,  "Positioned text blinks", MAX7456::Blink | MAX7456::LocalBG);
    osd->print(4, 10, " Blinks and inverse ", MAX7456::Blink | MAX7456::LocalBG | MAX7456::Inverse);
    
    while(1) {
        led1 = 1;
        wait(0.5);        
        led1 = 0;
        wait(0.5);    
    }
}

The OSD7456 API can be found here.

The full MAX7456 API can be found here.





7 comments:

28 Jul 2012

@All: Be sure to add a 1K pull-up resistor between VSYNC and VOUT (or the 5V supply of the MAX7456). According to the datasheet HSYNC and VSYNC are open drain, so without this the MBED won't see VSYNC interrupts so won't trigger the SPI transfer.

@Andy Kirkham: Having done the above, the initial results seem positive, but why have you limited OSD_NUM_LINES to 13 when the datasheet shows 16??

EDIT: Seems you can change OSD_NUM_LINES to 16 and then write to all 16 lines like this:

osd->print(0, "123456789012345678901234567890");
osd->print(15, "123456789012345678901234567890");

That works just fine

Steve.

07 May 2013

OK what am I doing wrong?

Quote:

no instance of constructor "mbed::SPI::SPI" matches the argument list

when I compile your program. I've tried it on the LPC1768 & KL25Z, I'm sure its finger trouble on my part.

Yours Simon M.

07 May 2013

Did you define the pins somewhere and are they valid SPI portpins:

#define MAX7456_MOSI  p5
#define MAX7456_MISO  p6
#define MAX7456_SCLK  p7
#define MAX7456_CS    p8
#define MAX7456_RST   p20
#define MAX7456_VSYNC p15
07 May 2013

Hi, these are the steps I took.

Set mbed to NXP LPC1768. > Create program MAX7456_TESTER. > Import your library. > Change main.cpp to >

Quote:

  1. define COMPILE_EXAMPLE_CODE_MODOSD7456
  2. define PCBAUD 115200
  3. define MAX7456_MOSI p5
  4. define MAX7456_MISO p6
  5. define MAX7456_SCLK p7
  6. define MAX7456_CS p8
  7. define MAX7456_RST p20
  8. define MAX7456_VSYNC p15
  9. include "/MODMAX7456/example1.cpp"

Compile, this fails with

Quote:

"cannot open source input file "/MODMAX7456/example1.cpp": No such file or directory" in file "/main.cpp", Line: 9, Col: 35 "no instance of constructor "mbed::SPI::SPI" matches the argument list" in file "MODMAX7456MAX7456.cpp", Line: 93, Col: 42

so I change line 9 to: #include "../MODMAX7456/example1.cpp" this removed first error, but the second is still there. I can see now that this will not work with the KL25Z, until I change the pin definitions. Yours Simon M.

07 May 2013

user Simon Markham wrote:

Compile, this fails with

Quote:

"no instance of constructor "mbed::SPI::SPI" matches the argument list" in file "MODMAX7456MAX7456.cpp", Line: 93, Col: 42

OK, that line says

    _ssp = new SPI(mosi, miso, sclk, name);

This must be an old version of the SPI lib. The current version does not support the ''name'' variable.

Try changing it to

    _ssp = new SPI(mosi, miso, sclk);

Note there may be more issues when this lib is old and has not been checked lately.

07 May 2013

That works! Thanks

So How do I you update the SPI library? I assumed that I would use the one built in to mbed?

Still pleased as this means I can move forward with this minor project... Yours Simon M.

10 May 2013

I've been playing around a bit more with this and I've got it to work with the KL25Z! Change pin numbers as so...

#define COMPILE_EXAMPLE_CODE_MODOSD7456
#define PCBAUD 115200
/*
//                    LPC1768       SparkFun
#define MAX7456_MOSI  p5    //DIN   pin 4
#define MAX7456_MISO  p6    //DOUT  pin 6
#define MAX7456_SCLK  p7    //SCK   pin 5
#define MAX7456_CS    p8    //CS    pin 3
#define MAX7456_RST   p20   //RST   pin 8
#define MAX7456_VSYNC p15   //VSYNC pin 10
*/

//                    KL25Z         SparkFun  Arduino
#define MAX7456_MOSI  PTD2  //DIN   pin 4   - D11   
#define MAX7456_MISO  PTD3  //DOUT  pin 6   - D12
#define MAX7456_SCLK  PTD1  //SCK   pin 5   - D13
#define MAX7456_CS    PTD0  //CS    pin 3   - D10
#define MAX7456_RST   PTA20 //RST   pin 8   - RST
#define MAX7456_VSYNC PTA13 //VSYNC pin 10  - D8
#include "../MODMAX7456/example1.cpp"

Yours Simon M.