The Max7456 from Maxim is a monochrome video overlay chip. With this you can overlay text and simple graphics over your PAL or NTSC video signal. You can also use it with no overlay, just like a simple monitor.

Included in this sample is a tutorial how you cam make your own characters with my converter tool. This tool converts the Maxim mcm files to Bascom data lines.

 

Syntax

Videotext string, y , x

Remarks

 String  String to be displayd
 y  Constant or variable with y position.
 x  Constant or variable with x position.

 

 

 

 

There are some controle characters implanted to controle (part of) the string.
Ascii 133=start blinking text, 134= stop blinking text
Ascii 131=enable the background, 132= disable the background
Ascii 135=invert text, 136= non-inverted text
In Bascom it’s easy to use this with {133} option, like:
Videotext “{133}Flashing text{134}”, 9 , 0

 

Syntax

Rowbrightness row, brightness

Remarks

Row  Row number to change 1-13 for NTSC , 1-16 for PAL
Brightness &B0000xx11 Character Black Level in % of OSD white level
00 = 0% 01 = 10% 10 = 20% 11 = 30%
&B000011xx Character White Level  in % of OSD white level
00 = 120%  01 = 100%  10 = 90% 11 = 80%

 

 

 

 

 

 

 

Syntax

Writecustomcharacter Characters

Remarks

Characters  Number of characters theat need to be programmed in the VRAM

 

 

Because the max7456 has NVM memory (eeprom) the writecustomercharacter routine only needs to be used one’s. The custom characters wil be left in the NVM memory even after power lost.

 

Downloads

Sample Bascom code , same as below
Maxim’s evaluation kit software , needed to edit the character table
Converter tool , to convert the mcm file.
Converter manual
Source code of the converter tool in VB6

And for the people who want to take it a step further, here a nice site (In German language) where is showed how to make your own graphics.

 

Update: 2009-03-24, Bug in the Bascom code and in the Converter tool, both fixed .
-Bascom: Max7456 was disabled in the Writecustomcharacter sub routine, but not enabled at the end of the sub.
-Converter tool: loops in exportarray was counting to 56 instead of 54, removed the loops and made fixed lines.

Example:

'=================================================
'=           MAX7456 Video overlay Demo          =
'=            By EvertDekker.com 2009            =
'= Created with Bascom-Avr: 1.11.9.3.001 license =
'=          No copyright for private use         =
'=                 Version 1.1                   =
'=================================================

$regfile = "m128def.DAT"
$crystal = 7372800
$baud = 19200
$hwstack = 75
$swstack = 75
$framesize = 50

Config Spi = Hard , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 16 , Noss = 0       'Setup the hardware spi
Spiinit                                                     'Init the spi bus

'=== Dimension ===
Dim Temp As Byte , Lus As Byte
Dim Regaddr As Byte
Dim Regdata As Byte
Dim Buffer(2) As Byte

Declare Sub Initmax7456()
Declare Sub Videotext(byval Text As String , Byval Ypos As Byte , Byval Xpos As Byte)
Declare Sub Writereg(byval Regaddr As Byte , Byval Regdata As Byte)
Declare Sub Rowbrightness(byval Row As Byte , Byval Brightness As Byte)
Declare Sub Writecustomcharacter(byval Characters As Byte)

'=== Const ===
Const Vm0 = &H00                                            'Video mode 1
Const Vm1 = &H01                                            'Video mode 2
Const Hos = &H02                                            'Horizontal Offset
Const Vos = &H03                                            'Vertical Offset
Const Dmm = &H04                                            'Display Memory Mode
Const Dmah = &H05                                           'Display Memory Address High
Const Dmal = &H06                                           'Display Memory Address Low
Const Dmdi = &H07                                           'Display Memory Data In
Const Cmm = &H08                                            'Character Memory Mode
Const Cmah = &H09                                           'Character Memory Address High
Const Cmal = &H0A                                           'Character Memory Address Low
Const Cmdi = &H0B                                           'Character Memory Data In
Const Osdm = &H0C                                           'Osd Insertion Mux
Const Osdbl = &H6C                                          'OSD Black Level
Const Readreg = &H80                                        'Read register = register + &H80
Const Status_read = &HA0                                    'Status register
Const True = 1
Const False = 0

'=== Main ===
Initmax7456                                                 'Init the Max7456
Waitms 100
Writecustomcharacter 3                                      'Write the customcharacters to the MAX7456 NVM, this has only need to be done one's. This line and data can be removed after that.

Do
Videotext "HELLO WORLD" , 1 , 8                             'Demo of the various possibilitys
Videotext "MAX7456 Video overlay" , 3 , 3
Videotext "Code written with Bascom-avr" , 4 , 0
Videotext "By Evertdekker.com" , 5 , 5
Videotext "{133}Flashing text{134}" , 9 , 0                 '{133}=start blinking text, {134}= stop blinking text
Videotext "{131}WITH BACKGROUND{132}" , 10 , 0              '{131}=enable the background, {132}= disable the background
Videotext "{135}Inverted TEXT{136}" , 11 , 0                '{135}=invert text, {136}= non-inverted text
Videotext "Adjust rowbrightness" , 12 , 0
Videotext "INCLUDE CUSTOM CHARS: + " , 7 , 0
'Rowbrightness 12 , &B00001111                               'Change the row brightness, see the SUB for the usage discription
Wait 5
Loop
End

'=== Subroutines===
Sub Initmax7456()
Writereg Vm0 , &B01001100
'01001000 ; 0 , 1=PAL, 00=Auto Sync, 1=Enable OSD, 0=Enable OSD always, 0=SW Reset, 0=Enable Video Buffer
Writereg Vm1 , &B01111111
'00010100 ; 0 = NA, 001=Background MODE Brightness 7%, 11=Blinking Time 160ms, 00=Blinking Duty Cycle BT:BT
Writereg Dmm , &B01000000
'01000000 ; 0=NA, 1=8bit operation,
Writereg Hos , &B00011111
'00011111 ; 00=NA, 00000000 = Farthest left (-32 pixels),00100000 = No horizontal offset, 00111111 = Farthest right (+31 pixels)
Writereg Vos , &B00010000
'00010000 ; 000=NA, 00000000 = Farthest up (+16 pixels), 00010000 = No vertical offset, 00011111 = Farthest down (-15 pixels)
End Sub

Sub Videotext(byval Text As String , Byval Ypos As Byte , Byval Xpos As Byte)
Local Charcount As Byte , Tempstring As String * 1 , Tempbyte As Byte , Position As Word , Chars As Byte , Controlcharcount As Byte , Attribute As Byte
Controlcharcount = 0 : Attribute = 0                        'Set the local variable to zero
Charcount = Len(text) - 1                                   'Count the number of characters in the string minus, because we must start at 0
For Chars = 0 To Charcount                                  'do the loop as much as there are characters
 Position = Ypos * 30                                       'Position where the characters must be showed 30=characters per line
 Position = Position + Xpos                                 'Position + the xpos
 Position = Position + Chars                                'Position + the charactercount that's handled this loop
 Position = Position - Controlcharcount                     'There was a controle charater, deduct from the charactercount because it must not be handled as real character
 Regdata = High(position)                                   'Put the highbyte of position in the regdatabuffer
 Writereg Dmah , Regdata                                    'Write the data to the register
 Regdata = Low(position)                                    'Put the lowbyte of position in the regdatabuffer
 Writereg Dmal , Regdata                                    'Write the data to the register
  Tempbyte = Chars + 1                                      'Need the character position from the textstring
 Tempstring = Mid(text , Tempbyte , 1)                      'Take out 1 character that we need to handle now
 Tempbyte = Asc(tempstring)                                 'Get the ascii value of this character
  If Tempbyte < 130 Then                                    'Character larger then 130 are controle characters
   Tempbyte = Tempbyte - 32                                 'Max7456 character table starts at &H00, so deduct 32 to get it even with the ascii table
   Regdata = Lookup(tempbyte , Characterslookup)            'Lookup the character from the datatable
   Writereg Dmdi , Regdata                                  'Write the data to the DisplayMemory register
  Else
   Incr Controlcharcount                                    'It's a controle character, increase the counter
   If Tempbyte = 131 Then Set Attribute.7                   'Set the local background bit in the character attribute
   If Tempbyte = 132 Then Reset Attribute.7                 'Reset the local background bit
   If Tempbyte = 133 Then Set Attribute.6                   'Set the blink bit
   If Tempbyte = 134 Then Reset Attribute.6                 'Reset the blink bit
   If Tempbyte = 135 Then Set Attribute.5                   'Set the inverse bit
   If Tempbyte = 136 Then Reset Attribute.5                 'Reset the inverse bit
  End If
 Regdata = High(position)                                   'Put the highbyte of position in the regdatabuffer
 Regdata = Regdata Or &B00000010                            'Set bit1 for the character attribute
 Writereg Dmah , Regdata                                    'Write the data to the register
 Regdata = Low(position)                                    'Put the lowbyte of position in the regdatabuffer
 Writereg Dmal , Regdata                                    'Write the data to the register
 Writereg Dmdi , Attribute                                  'Write the attribute to the DisplayMemory register
Next Carcount
End Sub


Sub Writecustomcharacter(byval Characters As Byte)
 Local Count As Byte
  Restore Customcharacter                                   'Goto the begin of the data
 For Count = 1 To Characters                                'Number of characters that need to be programmed, must match with the characters in the data
  Writereg Vm0 , &B01000100                                 'Disable osd
  Read Regdata                                              'Read the first databyte, is the character to will be programmed
  Writereg Cmah , Regdata                                   'Write to the register
  For Lus = 0 To 53                                         'Each Character is made of 54bytes
       Writereg Cmal , Lus                                  'Write the byteno of the character
       Read Regdata                                         'Read the data from the datatable
       Writereg Cmdi , Regdata                              'program the data in the shadowram
  Next Lus
  Writereg Cmm , &HA0                                       'Copy shadowram to NVram
  Waitms 200                                                'Wait until copy is ready
 Next Count
  Writereg Vm0 , &B01001100                                 'enable osd
End Sub

Sub Rowbrightness(byval Row As Byte , Byval Brightness As Byte)
If Brightness > &B00001111 Then Brightness = &B00001111     'B0000xx11 Character Black Level in % of OSD white level 00 = 0% 01 = 10% 10 = 20% 11 = 30%
Regaddr = &H10 + Row                                        'B000011xx Character White Level  in % of OSD white level 00 = 120%  01 = 100%  10 = 90% 11 = 80%
Regdata = Brightness
Writereg Regaddr , Regdata
End Sub

Sub Writereg(byval Regaddr As Byte , Byval Regdata As Byte)
 Buffer(1) = Regaddr                                        'Put both bytes in the array
 Buffer(2) = Regdata
 Spiout Buffer(1) , 2                                       'Shift the array out the SPI
End Sub


Characterslookup:
'Convert the ascii table to the Max7456 table. (Not excist) are characters that are not in the MAX7456 table and will show a ? (&H42)
Data &H00                                                   '32 Space
Data &H42                                                   '33 !  (not excist)
Data &H48                                                   '34 ""
Data &H42                                                   '35 # (not excist)
Data &H42                                                   '36 $ (not excist)
Data &H42                                                   '37 % (not excist)
Data &H42                                                   '38 & (not excist)
Data &H47                                                   '39 '
Data &H3F                                                   '40 (
Data &H40                                                   '41 )
Data &H42                                                   '42 * (not excist)
Data &H50                                                   '43 + (not excist)
Data &H45                                                   '44 ,
Data &H49                                                   '45 -
Data &H41                                                   '46 .
Data &H47                                                   '47 /
Data &H0A                                                   '48 0
Data &H01                                                   '49 1
Data &H02                                                   '50 2
Data &H03                                                   '51 3
Data &H04                                                   '52 4
Data &H05                                                   '53 5
Data &H06                                                   '54 6
Data &H07                                                   '55 7
Data &H08                                                   '56 8
Data &H09                                                   '57 9
Data &H44                                                   '58 :
Data &H43                                                   '59 ;
Data &H4A                                                   '60 <
Data &H42                                                   '61 = (not excist)
Data &H4B                                                   '62 >
Data &H42                                                   '63 ?
Data &H4C                                                   '64 @
Data &H0B                                                   '65 A
Data &H0C                                                   '66 B
Data &H0D                                                   '67 C
Data &H0E                                                   '68 D
Data &H0F                                                   '69 E
Data &H10                                                   '70 F
Data &H11                                                   '71 G
Data &H12                                                   '72 H
Data &H13                                                   '73 I
Data &H14                                                   '74 J
Data &H15                                                   '75 K
Data &H16                                                   '76 L
Data &H17                                                   '77 M
Data &H18                                                   '78 N
Data &H19                                                   '79 O
Data &H1A                                                   '80 P
Data &H1B                                                   '81 Q
Data &H1C                                                   '82 R
Data &H1D                                                   '83 S
Data &H1E                                                   '84 T
Data &H1F                                                   '85 U
Data &H20                                                   '86 V
Data &H21                                                   '87 W
Data &H22                                                   '88 X
Data &H23                                                   '89 Y
Data &H24                                                   '90 Z
Data &H42                                                   '91 [ (not excist)
Data &H42                                                   '92 \ (not excist)
Data &H42                                                   '93 ] (not excist)
Data &H42                                                   '94 ^ (not excist)
Data &H42                                                   '95 Underscore (not excist)
Data &H42                                                   '96 ` (not excist)
Data &H25                                                   '97 a
Data &H26                                                   '98 b
Data &H27                                                   '99 c
Data &H28                                                   '100 d
Data &H29                                                   '101 e
Data &H2A                                                   '102 f
Data &H2B                                                   '103 g
Data &H2C                                                   '104 h
Data &H2D                                                   '105 i
Data &H2E                                                   '106 j
Data &H2F                                                   '107 k
Data &H30                                                   '108 l
Data &H31                                                   '109 m
Data &H32                                                   '110 n
Data &H33                                                   '111 o
Data &H34                                                   '112 p
Data &H35                                                   '113 q
Data &H36                                                   '114 r
Data &H37                                                   '115 s
Data &H38                                                   '116 t
Data &H39                                                   '117 u
Data &H3A                                                   '118 v
Data &H3B                                                   '119 w
Data &H3C                                                   '120 x
Data &H3D                                                   '121 y
Data &H3E                                                   '122 z
Data &H42                                                   '123 {  (not excist)
Data &H42                                                   '124 |  (not excist)
Data &H42                                                   '125 }  (not excist)
Data &H42                                                   '126 ~  (not excist)

Customcharacter:
'Total of 3 characters in this datatable
Data &H50 ' Character 80
Data &H55, &H55, &H55, &H55, &H55, &H55, &H55, &H00
Data &H15, &H54, &HAA, &H85, &H52, &HAA, &HA1, &H52
Data &HA0, &HA8, &H52, &H85, &H28, &H02, &H80, &H41
Data &H2A, &HAA, &H15, &H2A, &HAA, &H15, &H42, &H80
Data &H55, &H2A, &HAA, &H15, &H2A, &HAA, &H01, &H02
Data &H85, &H28, &H52, &HA0, &HA8, &H52, &HAA, &HA1
Data &H54, &HAA, &H85, &H55, &H00, &H15
Data &H51 ' Character 81
Data &H55, &H55, &H55, &H55, &H55, &H55, &H55, &H55
Data &H55, &H55, &H56, &H55, &H55, &H56, &H55, &H55
Data &H56, &H55, &H6A, &HAA, &HAA, &H55, &H5A, &H55
Data &H55, &H66, &H55, &H55, &H66, &H55, &H55, &H96
Data &H55, &H55, &H96, &H55, &H56, &H56, &H55, &H59
Data &H56, &H55, &H65, &H56, &H55, &H55, &H56, &H55
Data &H55, &H5A, &H55, &H55, &H55, &H55
Data &H52 ' Character 82
Data &H55, &H55, &H55, &H55, &H55, &H55, &H55, &H55
Data &H55, &H55, &H59, &H55, &H55, &H59, &H55, &H55
Data &H59, &H55, &H6A, &HAA, &HAA, &H55, &H59, &H56
Data &H55, &H59, &H56, &H55, &H65, &H56, &H55, &H65
Data &H56, &H55, &H65, &H56, &H55, &H95, &H56, &H55
Data &H95, &H56, &H56, &H55, &H56, &H56, &H55, &H56
Data &H59, &H55, &H69, &H55, &H55, &H55