Main Site Documentation

Domino-MAX7456 Interface


#1

Hi,

I’d like to interface a MAX7456 to the Domino board.
This will be a fun project in order to learn how to write a .NET micro driver.
My problem is that the USBizi is a 3.3V device and the MAX7456 is a 5V device.
MAX7456’s datasheet states that the Vin-High level is 0.7*Vdd.
This is 3.5V if the MAX7456 runs from 5V.

Do you think a level conversion is needed on the SPI lines?
How do 5V shields connect to the Domino Board?

Thanks,
S.B.D


#2

USBizi is 5V tolerant to things re okay for the USBizi. Now, for your chip, you need some TTL logic. You will need a buffer or 2 inverters connected back to back. Or you can use some trnsistors but logic chip is easier.

It will be fun to see how your project running…and you will get a lot of experience points :slight_smile:


#3

Many Thanks!

Looks like I’m required to use something like a SN74LVC4245A for the CS,CLK & MOSI line.
Hope the local shop has them in stock.

Keep you posted on the progress.

Thanks,

S.B.D


#4

Hi,
Short update…
Instead of using the level shifter ic, I hooked up a discrete solution using an n-ch mosfet and two pullups. One towards the 3.3V rail and the other to the 5V rail.
Started out with 10k pullups @ 1MHz but it proved to much for the GPIO driver and line capacitance. Went down to 2.2k and decreases the clock to 500k. Output waveform looks fine.

Now comes my SPI question. Does the SPI driver support a Chip select line or does this need to be done in software via digital IO?

Thanks,
S.B.D


#5

Answering myself :D.

Its the first SPI configuration parameter.
I still need to play around with this to get the proper timing.
For some reason the CS line goes low only after the first 8 clocks.

Thanks,
S.B.D


#6

Hi,
Got the Dxx thing to write “Hello” on the TV.

Now for writing the driver.
Since I have zero experience in writing code over an OS I will require your assistance in this task.

How are .net drivers structured?
Can they depend on other drivers (like the SPI in this case)?

Your help or a link to good reading material will be appreciated.

Thanks,
S.B.D


#7

Hi,

Here is a basic MAX7456 class I wrote. Any comments for better coding will be appreciated!
I had a problem with the String.IndexOf method (c# didn’t like any way that I tried to invoke it… :(), so currently I have written this search myself.

How do I take this class and make it a true .net micro driver?

   

using System;
using System.Threading;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;
using Microsoft.SPOT;


public class MAX7456
{

    public const uint NTSC = 0;
    public const uint PAL = 1;

    static SPI.Configuration MaxSpiConfig =
    new SPI.Configuration((Cpu.Pin)FEZ_Pin.Digital.Di0,
    false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);

    SPI MaxSpi = new SPI(MaxSpiConfig);


    public void WriteString(uint PosX, uint PosY, string Str)
    {
        byte[] TxData = new byte[Str.Length];

        UInt16 PosXY = (UInt16)(PosY*30 + PosX);  //calc absolute position from x,y coordinates
        
        byte[] Character = new byte[37]    //character array NOT COMPLETE!!! 
        {
            32, //'space'
            49, //'1'
            50, //'2'
            51, //'3'
            52, //'4'
            53, //'5'
            54, //'6'
            55, //'7'
            56, //'8'
            57, //'9' 
     
            48, //'0'
            65, //'A'
            66,
            67,
            68,
            69,
            70,
            71,
            72,
            73,

            74,   //'J'
            75,
            76,
            77,
            78,
            79,
            80,
            81,
            82,
            83,

            84,    //'T'
            85,
            86,
            87,
            88,
            89,
            90    //'Z'

        };

        byte[] TempStr = System.Text.Encoding.UTF8.GetBytes(Str);   //convert string to byte array

        for (uint i = 0; i < TempStr.Length; i++)                   //character write loop
        {

            UInt16 PosXYTemp = PosXY;                               //buffer curser origin     

            PosXYTemp = (UInt16)(PosXYTemp + i);                    //move curser to next position
            uint PosHigh = (uint)(PosXYTemp >> 8);
            uint PosLow = (uint)(PosXYTemp - (PosHigh * 256));

            WriteReg(0x05, PosHigh);
            WriteReg(0x06, PosLow);
            byte u = TempStr[i];

            for (uint CharIndex = 0; CharIndex < Character.Length; CharIndex++) //search for   character in the array
            {
                if (Character[CharIndex] == u)
                {
                                                                    //character array to character matrix conversion
                    uint HighNibble = CharIndex / 16;               
                    uint LowNibble = CharIndex % 16;      //matrix y is low nibble, matrix x is low nibble
                    uint HighLow = HighNibble * 16 + LowNibble;     

                    WriteReg(0x07, HighLow);
                    break;
                }
            }
        }
    }


    public void WriteReg(uint Reg, uint Data)
    {
        byte[] TxData = new byte[2];
        byte[] RxData = new byte[2];

        TxData[0] = (byte)Reg;
        TxData[1] = (byte)Data;
        MaxSpi.WriteRead(TxData, RxData);
    }


    public uint ReadReg(uint Reg)
    {
        byte[] TxData = new byte[2];
        byte[] RxData = new byte[2];

        TxData[0] = (byte)Reg;
        TxData[1] = 0;
        MaxSpi.WriteRead(TxData, RxData);

        return (RxData[1]);   //read data is stored in byte #1 in RX array
    }


    public void Init(uint OffsetX, uint OffsetY, uint System)
    {
        uint PalNtsc = 0;

        WriteReg(0x00, 1);    //do a software reset
        Thread.Sleep(5);      //give enough time for reset to take place

        uint ReadData = ReadReg(0xec);   //read factory black level, set bit 4 and re-write
        WriteReg(0x6c, ReadData + 16);

        WriteReg(0x04, 0);

        WriteReg(0x02, OffsetX);      //x offset register
        WriteReg(0x03, OffsetY);      //y offset register

        if (System == PAL) PalNtsc = 0x48;  //set PAL or NTSC and enable OSD
        else PalNtsc = 0x08;
        WriteReg(0x00, PalNtsc);
    }



    public void ClearDisplay()
    {

        uint Temp = ReadReg(0x04);
        WriteReg(0x04,Temp + 4);      
        Thread.Sleep(5);
    }
}

 

Thanks,
S.B.D


#8

How about using the code function of the forum?


#9

No problem, figured out how to do it…


#10

Very cool work


#11

Thanks for the change! ;D