MAX7456 - Anyone used it with Basic Stamp? Practical code example needed.
CuriousOne
Posts: 931
Hello. I'm relatively new to basic stamp. I bought some basic stamps kits and studying everything slowly. Since I'm quite good in electronics, I'd like to do some practical examples. For that purpose, I've bought MAX7456 IC, built 24DIP adapter for it, including crystalls/etc.
I've searched this forum, everyone discusses the chip itself, but no code was shown. I don't care how much this chip consumes or how nice propeller is for video overlaying. I have basic stamp and I'd like to get maximum juice from it. So I'll be very grateful, if someone provides a simple basic code for MAX7456 interfacing. As I read the book, this chip is SPI driven, and SHIFTOUT command to be used. However, I see code in book, I see instructions to be sent in the IC manual, but I can't "connect" this two knowledge together. So, any help will be appreciated.
Sincerely,
Alex
I've searched this forum, everyone discusses the chip itself, but no code was shown. I don't care how much this chip consumes or how nice propeller is for video overlaying. I have basic stamp and I'd like to get maximum juice from it. So I'll be very grateful, if someone provides a simple basic code for MAX7456 interfacing. As I read the book, this chip is SPI driven, and SHIFTOUT command to be used. However, I see code in book, I see instructions to be sent in the IC manual, but I can't "connect" this two knowledge together. So, any help will be appreciated.
Sincerely,
Alex
Comments
There's a good reason why there are worked out simpler examples of SPI interfacing and other basic functions of the Stamps. The "What's a Microcontroller?" tutorial and StampWorks Manual are good starting points for learning the ins and outs of Stamp programming and the use of various kinds of hardware with the Stamps. The Nuts and Volts Columns also have good worked examples of more complex projects.
Say, we have 1602 LCD. To use with basic stamp, we have to issue set of specific commands via LCDCMD statement, to properly initialize and set the 1602 module.
So, I'm looking for something similar, but for MAX7456. For example, sparkfun supplies a C code, initialization section from which looks like this (copied just part):
I have some code you may find useful. This is an interesting chip and I use it on some of my projects. But one peculiarity is the character set: it's not ASCII. So unless you want to write a translation table for your data and text, you need to reprogram the character set. Fortunately this is easy to do. I have attached 3 programs to do this, and they serve as examples on how to interface to this chip. There are many more things you can do, so study the data sheet register tables to see what is possible. If you decide to use these programs, you need to run them in this order: Max7456_move, Max7456_prog and then Max7456_test.
The Max7456_move program moves as many characters as possible into their proper ASCII positions and overwrites all of the Asian characters.
The Max7456_prog program then writes all the missing ASCII characters. When done, $20-$7F are the proper ASCII characters except $60, for which a degree symbol replaces the grave accent. The original character set is saved in $80-$CD in case you want to restore it. The uppermost graphic characters $EC-$FF are not altered.
The Max7456_test program puts some static test data on the screen. In my production program this information is periodically updated. You can modify the code according to your needs.
A word of caution: Don't run the Max7456_move program more than once, or you'll lose some of the ASCII characters and then you’ll have to recreate them. There is no way to restore them once they are overwritten. The Max7456_prog program can be run whenever you want to update or change a character. Just change the DATA statements to meet your needs. I highly recommend you have the video output connected to a monitor and observe the character moves and programs as they run. You are prompted through the DEBUG port at each step of the move and programming process. Press "Y" or "y" to continue, anything else to stop.
All these programs use only 4 of the I/O lines on the Max7456 chip. They are /CS, SCLK, SDIN and SDOUT. The pin assignments are shown at the top of each program. Change them according to your setup. Since the BS2 is too slow to write during the vertical blanking interval, I do not use /VSYNC or any of the other I/O pins. RESET is tied to DVDD.
Actually, I forgot to look into this thread untill now. Now I assembled the circuit and everything works just fine!
Just a little problem, it seems that I've terminated the _move.bs2 too early, so not all characters were moved, for example, now I have "V" letter instead of spacebar and there are no small letters. Any way to fix this?
However, to be sure, run the Max7456_move to get the current characters on the video screen (answer "Y" twice, and "N" to Write done. Move charcaters?) to see what moved and what didn't. Take a picture of the video screen, and attach it to your reply and I might be able to tell you if it is okay to proceed, or if you need to comment out some of the DATA statements.
You can look at the DATA statements in the Max7456_move to see where you stopped. I move the characters in groups. Comment out all the DATA statements at the end of the program for the characters that were moved, and put MT in front of the next (uncommented) DATA statement. Run your modified move program, and it should pick up where you left off and finish moving the characters.
Thanks a lot, here it is.
Also, I've studied the .mcm font file, created by max 7456EVKIT software. As it appears, characters start at 0 position, right? so to get correct mapping, we need to shift them by 32?
What I don't know is why there are characters on your screen that aren't in the default set, like the arrows in rows 7 and 8. They aren't part of the default chip font, and I don't progam them. Is it possible this chip was used before by someone else who added these characters? If so, then my programs won't work for you because many of the characters are in the wrong positions and there are no lower case letters.
At this point, it may be best to just completely overwrite the font table with the font you want. You'll have to write a program to send each character's bit-map. That's tedious, but there are examples in my Max7456prog program on how to make some of them with DATA statements. My guess is you will have to take the .mcm file on you PC and convert it to DATA statements for the BS2 to send to the chip. It will be a lot of work. I've attached an ascii_only.txt file that so you can see what it should look like (rename it .mcm to load into the EVKIT).
Is a result of reading 48 lines from .mcm file, and binary code from each line is converted into hex code, right?
1. Your code shows 48 bytes per char, when according to datasheet, there should be 3x18=54 bytes per char.
2. But if we count number of lines in sample .mcm files provided, it is 16384 (16385 with leading "MAX7456 text") considering we have 256 chars total, this translates 16384/256=64 lines per char.
I'm very confused....
You may need more than one program to write them all if the DATA is too much, but that's not a problem because you're only going to use it once and only the DATA statements and starting point change. And if you're using my .mcm file, you only need to write 96 of the 256 characters. All the rest are blank which you could do in a loop first.
Regarding the characters, ok, yours does not use all rows, but how that applies to .MCM file structure? and again, 64 lines in actual file, 56 lines in MCM, very strange....
If anyone interested, here's the code in visual studio express, which reads .mcm file and output basic stamp compatible code (HEX data)
Then either modifying my program, or writing your own, in a loop read the first DATA byte to set the address in the MAX7456, and then send the next 54 DATA bytes that define the character. Repeat until you run out of data. Determine this by having a special first byte value of say zero which means your done.
In my max7456_prog program, I put the destination in the CM DATA statement because I had scattered characters. So you'd only have to change the main DO loop to read the first DATA byte in your program, and watch for the ending byte. The first DATA statement has to be proceeded by "PC" and there has to be a trailing DATA 0 at the end.
Here is the modified code:
Also, since I want to update complete ASCII table (chars 33-255), I should adjust my "CM" sting to have values for all chars, right?
And what it I want to have all 64 bytes updated? (Just for ease of .mcm file reading), I think, FOR x = 1 TO 54 should be counting up to 64 ?
You can send all 64 bytes, but the MAX7456 ignores any above 54 so it only wastes DATA space, but won't hurt the chip. You'll also have to change the 55*list to 65*list (in two places) if you do it this way.
You don't need the CM label, and the first DATA byte ($41) needs to be on the PC line. Or, if you want to do it this way, put PC on the first DATA line (the one with $41) and no label on the successive lines. You must have a final DATA 0 at the end though, otherwise the program will read into program memory and write garbage to the MAX7456.
Regarding the CM, the $41 is ASCII code for letter "A". If it will be missing, how program will determine which DATA to write to which area?
BTW, I've prepared a standard .mcm file, with all ASCII characters distributed according to standard. Also, shape of certain letters was adjusted. I can upload it, if anyone needs.