Max7456 video overlay

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.

Osd with background
PlayPause
previous arrow
next arrow
Osd with background
Osd with background
Osd with no background
Software
previous arrow
next arrow

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:

1'=================================================
2'=           MAX7456 Video overlay Demo          =
3'=            By EvertDekker.com 2009            =
4'= Created with Bascom-Avr: 1.11.9.3.001 license =
5'=          No copyright for private use         =
6'=                 Version 1.1                   =
7'=================================================
8 
9$regfile = "m128def.DAT"
10$crystal = 7372800
11$baud = 19200
12$hwstack = 75
13$swstack = 75
14$framesize = 50
15 
16Config Spi = Hard , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 16 , Noss = 0       'Setup the hardware spi
17Spiinit                                                     'Init the spi bus
18 
19'=== Dimension ===
20Dim Temp As Byte , Lus As Byte
21Dim Regaddr As Byte
22Dim Regdata As Byte
23Dim Buffer(2) As Byte
24 
25Declare Sub Initmax7456()
26Declare Sub Videotext(byval Text As String , Byval Ypos As Byte , Byval Xpos As Byte)
27Declare Sub Writereg(byval Regaddr As Byte , Byval Regdata As Byte)
28Declare Sub Rowbrightness(byval Row As Byte , Byval Brightness As Byte)
29Declare Sub Writecustomcharacter(byval Characters As Byte)
30 
31'=== Const ===
32Const Vm0 = &H00                                            'Video mode 1
33Const Vm1 = &H01                                            'Video mode 2
34Const Hos = &H02                                            'Horizontal Offset
35Const Vos = &H03                                            'Vertical Offset
36Const Dmm = &H04                                            'Display Memory Mode
37Const Dmah = &H05                                           'Display Memory Address High
38Const Dmal = &H06                                           'Display Memory Address Low
39Const Dmdi = &H07                                           'Display Memory Data In
40Const Cmm = &H08                                            'Character Memory Mode
41Const Cmah = &H09                                           'Character Memory Address High
42Const Cmal = &H0A                                           'Character Memory Address Low
43Const Cmdi = &H0B                                           'Character Memory Data In
44Const Osdm = &H0C                                           'Osd Insertion Mux
45Const Osdbl = &H6C                                          'OSD Black Level
46Const Readreg = &H80                                        'Read register = register + &H80
47Const Status_read = &HA0                                    'Status register
48Const True = 1
49Const False = 0
50 
51'=== Main ===
52Initmax7456                                                 'Init the Max7456
53Waitms 100
54Writecustomcharacter 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.
55 
56Do
57Videotext "HELLO WORLD" , 1 , 8                             'Demo of the various possibilitys
58Videotext "MAX7456 Video overlay" , 3 , 3
59Videotext "Code written with Bascom-avr" , 4 , 0
60Videotext "By Evertdekker.com" , 5 , 5
61Videotext "{133}Flashing text{134}" , 9 , 0                 '{133}=start blinking text, {134}= stop blinking text
62Videotext "{131}WITH BACKGROUND{132}" , 10 , 0              '{131}=enable the background, {132}= disable the background
63Videotext "{135}Inverted TEXT{136}" , 11 , 0                '{135}=invert text, {136}= non-inverted text
64Videotext "Adjust rowbrightness" , 12 , 0
65Videotext "INCLUDE CUSTOM CHARS: + " , 7 , 0
66'Rowbrightness 12 , &B00001111                               'Change the row brightness, see the SUB for the usage discription
67Wait 5
68Loop
69End
70 
71'=== Subroutines===
72Sub Initmax7456()
73Writereg Vm0 , &B01001100
74'01001000 ; 0 , 1=PAL, 00=Auto Sync, 1=Enable OSD, 0=Enable OSD always, 0=SW Reset, 0=Enable Video Buffer
75Writereg Vm1 , &B01111111
76'00010100 ; 0 = NA, 001=Background MODE Brightness 7%, 11=Blinking Time 160ms, 00=Blinking Duty Cycle BT:BT
77Writereg Dmm , &B01000000
78'01000000 ; 0=NA, 1=8bit operation,
79Writereg Hos , &B00011111
80'00011111 ; 00=NA, 00000000 = Farthest left (-32 pixels),00100000 = No horizontal offset, 00111111 = Farthest right (+31 pixels)
81Writereg Vos , &B00010000
82'00010000 ; 000=NA, 00000000 = Farthest up (+16 pixels), 00010000 = No vertical offset, 00011111 = Farthest down (-15 pixels)
83End Sub
84 
85Sub Videotext(byval Text As String , Byval Ypos As Byte , Byval Xpos As Byte)
86Local Charcount As Byte , Tempstring As String * 1 , Tempbyte As Byte , Position As Word , Chars As Byte , Controlcharcount As Byte , Attribute As Byte
87Controlcharcount = 0 : Attribute = 0                        'Set the local variable to zero
88Charcount = Len(text) - 1                                   'Count the number of characters in the string minus, because we must start at 0
89For Chars = 0 To Charcount                                  'do the loop as much as there are characters
90 Position = Ypos * 30                                       'Position where the characters must be showed 30=characters per line
91 Position = Position + Xpos                                 'Position + the xpos
92 Position = Position + Chars                                'Position + the charactercount that's handled this loop
93 Position = Position - Controlcharcount                     'There was a controle charater, deduct from the charactercount because it must not be handled as real character
94 Regdata = High(position)                                   'Put the highbyte of position in the regdatabuffer
95 Writereg Dmah , Regdata                                    'Write the data to the register
96 Regdata = Low(position)                                    'Put the lowbyte of position in the regdatabuffer
97 Writereg Dmal , Regdata                                    'Write the data to the register
98  Tempbyte = Chars + 1                                      'Need the character position from the textstring
99 Tempstring = Mid(text , Tempbyte , 1)                      'Take out 1 character that we need to handle now
100 Tempbyte = Asc(tempstring)                                 'Get the ascii value of this character
101  If Tempbyte < 130 Then                                    'Character larger then 130 are controle characters
102   Tempbyte = Tempbyte - 32                                 'Max7456 character table starts at &H00, so deduct 32 to get it even with the ascii table
103   Regdata = Lookup(tempbyte , Characterslookup)            'Lookup the character from the datatable
104   Writereg Dmdi , Regdata                                  'Write the data to the DisplayMemory register
105  Else
106   Incr Controlcharcount                                    'It's a controle character, increase the counter
107   If Tempbyte = 131 Then Set Attribute.7                   'Set the local background bit in the character attribute
108   If Tempbyte = 132 Then Reset Attribute.7                 'Reset the local background bit
109   If Tempbyte = 133 Then Set Attribute.6                   'Set the blink bit
110   If Tempbyte = 134 Then Reset Attribute.6                 'Reset the blink bit
111   If Tempbyte = 135 Then Set Attribute.5                   'Set the inverse bit
112   If Tempbyte = 136 Then Reset Attribute.5                 'Reset the inverse bit
113  End If
114 Regdata = High(position)                                   'Put the highbyte of position in the regdatabuffer
115 Regdata = Regdata Or &B00000010                            'Set bit1 for the character attribute
116 Writereg Dmah , Regdata                                    'Write the data to the register
117 Regdata = Low(position)                                    'Put the lowbyte of position in the regdatabuffer
118 Writereg Dmal , Regdata                                    'Write the data to the register
119 Writereg Dmdi , Attribute                                  'Write the attribute to the DisplayMemory register
120Next Carcount
121End Sub
122 
123 
124Sub Writecustomcharacter(byval Characters As Byte)
125 Local Count As Byte
126  Restore Customcharacter                                   'Goto the begin of the data
127 For Count = 1 To Characters                                'Number of characters that need to be programmed, must match with the characters in the data
128  Writereg Vm0 , &B01000100                                 'Disable osd
129  Read Regdata                                              'Read the first databyte, is the character to will be programmed
130  Writereg Cmah , Regdata                                   'Write to the register
131  For Lus = 0 To 53                                         'Each Character is made of 54bytes
132       Writereg Cmal , Lus                                  'Write the byteno of the character
133       Read Regdata                                         'Read the data from the datatable
134       Writereg Cmdi , Regdata                              'program the data in the shadowram
135  Next Lus
136  Writereg Cmm , &HA0                                       'Copy shadowram to NVram
137  Waitms 200                                                'Wait until copy is ready
138 Next Count
139  Writereg Vm0 , &B01001100                                 'enable osd
140End Sub
141 
142Sub Rowbrightness(byval Row As Byte , Byval Brightness As Byte)
143If Brightness > &B00001111 Then Brightness = &B00001111     'B0000xx11 Character Black Level in % of OSD white level 00 = 0% 01 = 10% 10 = 20% 11 = 30%
144Regaddr = &H10 + Row                                        'B000011xx Character White Level  in % of OSD white level 00 = 120%  01 = 100%  10 = 90% 11 = 80%
145Regdata = Brightness
146Writereg Regaddr , Regdata
147End Sub
148 
149Sub Writereg(byval Regaddr As Byte , Byval Regdata As Byte)
150 Buffer(1) = Regaddr                                        'Put both bytes in the array
151 Buffer(2) = Regdata
152 Spiout Buffer(1) , 2                                       'Shift the array out the SPI
153End Sub
154 
155 
156Characterslookup:
157'Convert the ascii table to the Max7456 table. (Not excist) are characters that are not in the MAX7456 table and will show a ? (&H42)
158Data &H00                                                   '32 Space
159Data &H42                                                   '33 !  (not excist)
160Data &H48                                                   '34 ""
161Data &H42                                                   '35 # (not excist)
162Data &H42                                                   '36 $ (not excist)
163Data &H42                                                   '37 % (not excist)
164Data &H42                                                   '38 & (not excist)
165Data &H47                                                   '39 '
166Data &H3F                                                   '40 (
167Data &H40                                                   '41 )
168Data &H42                                                   '42 * (not excist)
169Data &H50                                                   '43 + (not excist)
170Data &H45                                                   '44 ,
171Data &H49                                                   '45 -
172Data &H41                                                   '46 .
173Data &H47                                                   '47 /
174Data &H0A                                                   '48 0
175Data &H01                                                   '49 1
176Data &H02                                                   '50 2
177Data &H03                                                   '51 3
178Data &H04                                                   '52 4
179Data &H05                                                   '53 5
180Data &H06                                                   '54 6
181Data &H07                                                   '55 7
182Data &H08                                                   '56 8
183Data &H09                                                   '57 9
184Data &H44                                                   '58 :
185Data &H43                                                   '59 ;
186Data &H4A                                                   '60 <
187Data &H42                                                   '61 = (not excist)
188Data &H4B                                                   '62 >
189Data &H42                                                   '63 ?
190Data &H4C                                                   '64 @
191Data &H0B                                                   '65 A
192Data &H0C                                                   '66 B
193Data &H0D                                                   '67 C
194Data &H0E                                                   '68 D
195Data &H0F                                                   '69 E
196Data &H10                                                   '70 F
197Data &H11                                                   '71 G
198Data &H12                                                   '72 H
199Data &H13                                                   '73 I
200Data &H14                                                   '74 J
201Data &H15                                                   '75 K
202Data &H16                                                   '76 L
203Data &H17                                                   '77 M
204Data &H18                                                   '78 N
205Data &H19                                                   '79 O
206Data &H1A                                                   '80 P
207Data &H1B                                                   '81 Q
208Data &H1C                                                   '82 R
209Data &H1D                                                   '83 S
210Data &H1E                                                   '84 T
211Data &H1F                                                   '85 U
212Data &H20                                                   '86 V
213Data &H21                                                   '87 W
214Data &H22                                                   '88 X
215Data &H23                                                   '89 Y
216Data &H24                                                   '90 Z
217Data &H42                                                   '91 [ (not excist)
218Data &H42                                                   '92 \ (not excist)
219Data &H42                                                   '93 ] (not excist)
220Data &H42                                                   '94 ^ (not excist)
221Data &H42                                                   '95 Underscore (not excist)
222Data &H42                                                   '96 ` (not excist)
223Data &H25                                                   '97 a
224Data &H26                                                   '98 b
225Data &H27                                                   '99 c
226Data &H28                                                   '100 d
227Data &H29                                                   '101 e
228Data &H2A                                                   '102 f
229Data &H2B                                                   '103 g
230Data &H2C                                                   '104 h
231Data &H2D                                                   '105 i
232Data &H2E                                                   '106 j
233Data &H2F                                                   '107 k
234Data &H30                                                   '108 l
235Data &H31                                                   '109 m
236Data &H32                                                   '110 n
237Data &H33                                                   '111 o
238Data &H34                                                   '112 p
239Data &H35                                                   '113 q
240Data &H36                                                   '114 r
241Data &H37                                                   '115 s
242Data &H38                                                   '116 t
243Data &H39                                                   '117 u
244Data &H3A                                                   '118 v
245Data &H3B                                                   '119 w
246Data &H3C                                                   '120 x
247Data &H3D                                                   '121 y
248Data &H3E                                                   '122 z
249Data &H42                                                   '123 {  (not excist)
250Data &H42                                                   '124 |  (not excist)
251Data &H42                                                   '125 }  (not excist)
252Data &H42                                                   '126 ~  (not excist)
253 
254Customcharacter:
255'Total of 3 characters in this datatable
256Data &H50 ' Character 80
257Data &H55, &H55, &H55, &H55, &H55, &H55, &H55, &H00
258Data &H15, &H54, &HAA, &H85, &H52, &HAA, &HA1, &H52
259Data &HA0, &HA8, &H52, &H85, &H28, &H02, &H80, &H41
260Data &H2A, &HAA, &H15, &H2A, &HAA, &H15, &H42, &H80
261Data &H55, &H2A, &HAA, &H15, &H2A, &HAA, &H01, &H02
262Data &H85, &H28, &H52, &HA0, &HA8, &H52, &HAA, &HA1
263Data &H54, &HAA, &H85, &H55, &H00, &H15
264Data &H51 ' Character 81
265Data &H55, &H55, &H55, &H55, &H55, &H55, &H55, &H55
266Data &H55, &H55, &H56, &H55, &H55, &H56, &H55, &H55
267Data &H56, &H55, &H6A, &HAA, &HAA, &H55, &H5A, &H55
268Data &H55, &H66, &H55, &H55, &H66, &H55, &H55, &H96
269Data &H55, &H55, &H96, &H55, &H56, &H56, &H55, &H59
270Data &H56, &H55, &H65, &H56, &H55, &H55, &H56, &H55
271Data &H55, &H5A, &H55, &H55, &H55, &H55
272Data &H52 ' Character 82
273Data &H55, &H55, &H55, &H55, &H55, &H55, &H55, &H55
274Data &H55, &H55, &H59, &H55, &H55, &H59, &H55, &H55
275Data &H59, &H55, &H6A, &HAA, &HAA, &H55, &H59, &H56
276Data &H55, &H59, &H56, &H55, &H65, &H56, &H55, &H65
277Data &H56, &H55, &H65, &H56, &H55, &H95, &H56, &H55
278Data &H95, &H56, &H56, &H55, &H56, &H56, &H55, &H56
279Data &H59, &H55, &H69, &H55, &H55, &H55