I’m working on my MAX7456 OSD interface again (temporarily replaced my fried Panda with one from another project). I’m trying to get the performance where it needs to be. In the .Net Micro Framework, that usually comes down to having the framework do as much of the work as possible, especially iterative operations.
The following code snippet, I’m writing text to the display memory. The way I have it now, I’m writing the array of byte[] charValues to SPI in a single step. For some reason, every other character is dropped when I do it this way. When I comment out that line and uncomment out the loop below, it all works fine.
WriteSPI((byte)Registers.Write_DMM, (byte)(DMM_Values.OperationMode_16bit | DMM_Values.AutoIncrement_Enabled ));
spi.Write(charValues);
//for (int x = 0; x < charValues.Length; x++)
//{
// WriteSPI(charValues[x]);
// //Debug.Print("Offset=" + this.CharOffset);
//}
WriteSPI((byte)0xff);
WriteSPI((byte)Registers.Write_VM0, (byte)(VH0_Values.Sync_NextVSync | VH0_Values.OSD_On));
// declared elsewhere:
byte[] spiWriteBuf1 = new byte[1];
byte[] spiWriteBuf2 = new byte[2];
private void WriteSPI(byte data)
{
spiWriteBuf1[0] = data;
spi.Write(spiWriteBuf1);
}
private void WriteSPI(byte reg, byte data)
{
spiWriteBuf2[0] = reg;
spiWriteBuf2[1] = data;
spi.Write(spiWriteBuf2);
}
If the performance difference wasn’t so massive, I wouldn’t worry about it. But I need the SPEED.
I’m not sure if the OSD is busy and is dropping the data, or if there’s some kind of weird timing issue going on. I tried slowing the transfer rate, tweaking the SPI parameters for HoldTime, SetupTime, etc. (But I can’t say I exhausted the options there.) I know the MF SPI interface supports a busy bit but the MAX7456 doesn’t. I have a hack going now where I write a ushort instead of a byte so I’m still dropping but just spacing out my data. But I’m wasting cycles formatting the data that way so it’s still slow.
Does anyone have any ideas on this?!?!
Here’s the SPI setup config I’m using now:
SPI.Configuration(pin, false, 0, 0, false, true, 10000,module)