Problem AND Solution - LCD Initialization
I have no conditions to do this in real life, so it may be wrong. But it happens if simulated with Proteus V7.5 SP3.
I don't know why, but I found the BS2 to be quite interesting. I learned to use it myself and it really is interesting. I've even programmed a control for a simple elevator. But then I was looking for more commands to learn and I stumbled upon the LCD commands. I've read the datasheet, set up everything, copied the LCD initialization code, started the simulation and... nothing. Tried a lot of different things and... nothing. Proteus said that the BS2 tried to read the LCD after a single nibble. I looked at the init sequence and suspected it could be it. It was sending byte after byte, and I remembered of a init sequence I made for a PIC in C. It sends a single nibble then the bytes. I adapted it to PBasic and... it worked! I wonder if the init sequence presented in the BS2 datasheet works in real life. But to work in the simulation, do this:
LOW 2 'low rw
LOW 3 'low rs
DIRB = $FF 'data to bus
OUTB = 2
HIGH 1 'enable pulse
PAUSE 2
LOW 1
LCDCMD 1, $28 'rest of it
LCDCMD 1, $06
LCDCMD 1, $0c
LCDCMD 1, $01
PAUSE 2 'to be sure
I don't know why, but I found the BS2 to be quite interesting. I learned to use it myself and it really is interesting. I've even programmed a control for a simple elevator. But then I was looking for more commands to learn and I stumbled upon the LCD commands. I've read the datasheet, set up everything, copied the LCD initialization code, started the simulation and... nothing. Tried a lot of different things and... nothing. Proteus said that the BS2 tried to read the LCD after a single nibble. I looked at the init sequence and suspected it could be it. It was sending byte after byte, and I remembered of a init sequence I made for a PIC in C. It sends a single nibble then the bytes. I adapted it to PBasic and... it worked! I wonder if the init sequence presented in the BS2 datasheet works in real life. But to work in the simulation, do this:
LOW 2 'low rw
LOW 3 'low rs
DIRB = $FF 'data to bus
OUTB = 2
HIGH 1 'enable pulse
PAUSE 2
LOW 1
LCDCMD 1, $28 'rest of it
LCDCMD 1, $06
LCDCMD 1, $0c
LCDCMD 1, $01
PAUSE 2 'to be sure