PDA

View Full Version : I2C LCD



midali
- 26th December 2014, 12:57
Merry XMAS to all!
I'm back with another problem. Its first time when I work with I2C .
I have a 1x LCD with 8 pins, I suppose that have a controller ST7036i or ST7032i (pin2, pin3 = NC) and also I have a LCD with 7 pins , TM202SIFSUGWA with ST7036i controller(pin2 = NC) . I tried to display a text but I have nothing on LCD.

I used this schematic:

7615

Code :

#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG

OSCCON = %01101010 'sets the internal oscillator to 4Mhz

TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
WPUA = %00000000
WPUC = %00000011

PORTA = 0
PORTC = 0

SCL VAR PORTC.0
SDA var PORTC.1
RESET var PORTC.2 ; IT'S REQUIRED?

cbyte var byte 'CONTROL BYTE FOR DATA
I2C var byte 'CONTROL BYTE FOR CONTROL CODES

cbyte = 0 'USE TO send a command
I2C = $7C 'ADDRESS FROM MANUAL ??

main:

I2CWRITE SDA,SCL,I2C,cbyte,[$25] 'contrast
PAUSE 1
I2CWRITE SDA,SCL,I2C,cbyte,["HELLO"] 'print on the first line
pause 3000

goto main
end

Pls, can somebody help me ?

1000 x thx !

midali
- 26th December 2014, 19:20
#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG

OSCCON = %01101010 'sets the internal oscillator to 4Mhz

TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
WPUA = %00000000
WPUC = %00000011

PORTA = 0
PORTC = 0

SCL VAR PORTC.0
SDA var PORTC.1
RESET var PORTC.2 ; IT'S REQUIRED?

cbyte var byte 'CONTROL BYTE FOR DATA
I2C var byte 'CONTROL BYTE FOR CONTROL CODES

cbyte = 0 'USE TO send a command
I2C = $7C 'ADDRESS FROM MANUAL ??

main:

I2CWRITE SDA,SCL,I2C,cbyte,[$25] 'contrast
PAUSE 1
I2CWRITE SDA,SCL,I2C,cbyte,["HELLO"] 'print on the first line
pause 3000

goto main
end

Demon
- 26th December 2014, 21:33
It might be working but the lcd might not have high enough contrast.

Usually, V0 is not VDD.

Try a 20K variable resistor, V0 to center pin, VDD to one side, GND to other side.

Now turn resistor and look at LCD for changes.

Edit: also increase pause between writes to lcd in case it needs more time. Try PAUSE500 to test.

Robert

midali
- 27th December 2014, 09:58
Thx Robert for suggestion ..I tried like schematic, but nothing...
A question : on this LCD type I must see a dots when I play cu variable resistor ? Or first time ,lcd must be initialized ?

7617

Amoque
- 27th December 2014, 12:12
You can start by seeing the "squares" where the characters will appear darken. Once you get something going - adjust to taste.

DaveC3
- 27th December 2014, 13:56
I do not see RESET set to any value. Portc is 0. Most LCDs I have work with the reset line needs to be high. (except if you are resetting) I could not find a data sheet so not sure about your display.

Dave

Demon
- 27th December 2014, 14:03
Yeah, couldn't find anything either.

Try adding a PAUSE 250 before writes to give time to lcd to initialize.

Robert

Demon
- 27th December 2014, 14:07
...
Try a 20K variable resistor, V0 to center pin, VDD to one side, GND to other side.
...

You still need VDD to pin 4.

Robert

Demon
- 27th December 2014, 14:12
2C = $7C 'ADDRESS FROM MANUAL ??

What manual? Do you have a link?

Robert

midali
- 27th December 2014, 15:03
So , I found a working factory motherboard with LCD ( 7 pins) , TM202SIFSUGWA ,with ST7036i controller .
I measured the voltage on pin V0 =3.87 V , then I desoldered the lcd and I tried to set contrast with a variable resistor...nothing on LCD!
My conclusion is that contrast must set from software. I'm wrong ?

midali
- 27th December 2014, 15:43
Really I have more different LCD display's, with 7 and 8 pins.
I tried with:
- 8 pins LCD (TM202TCCWUGWA) ...I suppose that have ST7032i controller
- 7 pins LCD (TM202SGFSGWA-B-1A ) ...I'm sure that have ST7036i controller

I not found datasheets for them, but I suppose that important is the controller.
Recently I found some information about ST7032, see atach. 7618
Here is a link with the same LCD ( I guess) http://www.farnell.com/datasheets/1669635.pdf

New code (not working)

SCL VAR PORTC.0
SDA var PORTC.1
RESET var PORTC.2 ; IT'S REQUIRED?

cbyte var byte 'CONTROL BYTE FOR DATA
I2C var byte 'CONTROL BYTE FOR CONTROL CODES

cbyte = 4 'USE TO send a command
I2C = $7C 'ADDRESS FROM MANUAL ??
high reset

main:

I2CWRITE SDA,SCL,I2C,cbyte,["HELLO"] 'print on the first line
pause 250

goto main
end

Demon
- 27th December 2014, 16:08
Add PAUSE 250 before Main, LCD must stabilize.

(Will look at datasheet)

Robert

Demon
- 27th December 2014, 16:14
Look at I2C commands in PBP manual. You are missing DEFINEs.

Robert

Demon
- 27th December 2014, 16:32
Start reading at p. 33.

Www.akizukidenshi.com/download/ds/sitronix/st7032.pdf

Robert

midali
- 27th December 2014, 20:10
For me is too hard because I write in basic code only few lines in my life. Your start point is welocome for me.
I appreciate your help Robert! Thank you very much!

DaveC3
- 27th December 2014, 22:11
To inilalize this display wyou need to write something like this


high RESET
pause 10
low RESET
pause 10
high RESET

I2CWRITE datapin, clockpin,$7C[$80,$57,$80,$6C,$80,$01,$80,$02]


before you can write to the display


I2CWRITE datapin, clockpin,$7C[$80,$80,$40,$48,$45,$$4C,$4c,$4F] 'HELLO

I do not have a display to test so not sure if this will work, but this is what I would start with, I took the code from the data sheet.

Dave

Demon
- 28th December 2014, 00:17
You might want to put a resistor on RESET pin, at least 1K.

Robert

midali
- 28th December 2014, 11:40
I measured on working original board with ST7036i controller , 5V Vdd :
V0 pin = 3,82V (voltage from a divider with 2 resistors)
SDA = 150 ohm resistor between PIC pin and SDA LCD pin
SCL = to PIC pin
SDA and SCL = 1k to 5V
RESET = to PIC pin and 1nF capacitor to GND
RESET pin is all time to HIGH

A question : SDA and SCL pins from LCD must connect with SDA and SCL pins from PIC or I can connect to any pins pic ?

midali
- 28th December 2014, 18:29
To inilalize this display wyou need to write something like this


high RESET
pause 10
low RESET
pause 10
high RESET

I2CWRITE datapin, clockpin,$7C[$80,$57,$80,$6C,$80,$01,$80,$02]


before you can write to the display


I2CWRITE datapin, clockpin,$7C[$80,$80,$40,$48,$45,$$4C,$4c,$4F] 'HELLO

I do not have a display to test so not sure if this will work, but this is what I would start with, I took the code from the data sheet.

Dave

Thx Dave, I tried but nothing!
I tried a code for 7036i controller, with V0 connected to Vdd , but I feel that somewhere I'm wrong in DEFINE LCD .
I know that your help eat a lot of time, but if somebody have a free time to read in datasheet and help me, I'll appreciate!
Datasheet 7036i : http://www.datasheetarchive.com/dlmain/Datasheets-32/DSA-621251.pdf

Code :


'PIC 16F1824

#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG

OSCCON = %01101010 'sets the internal oscillator to 4Mhz

TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
WPUA = %00000000
WPUC = %00000011

PORTA = 0
PORTC = 0

SCL VAR PORTC.0
SDA var PORTC.1
RS var PORTC.2
symbol mode = $7C

pause 100
RS = 0
'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)

'=============Initializing by Instruction==========pag 39 datasheet

'CLEAR LCD --------------pag 28 datasheet
I2CWRITE sda, scl,mode,[$01]
pause 10

'ENTRY MODE SET----------
I2CWRITE sda, scl,mode,[$07] 'cursor/blink moves to right and DDRAM address is increased by 1.
pause 10

'FUNCTION SET------------pag 30 datasheet
I2CWRITE sda, scl,mode,[$38] ' 8 bit, 2 lines, font normal, instruction table 0
pause 10

'CURSOR DISPLAY------------pag 29 datasheet
I2CWRITE sda, scl,mode,[$14]
pause 10

'INTERNAL OSC------------pag 35 datasheet
I2CWRITE sda, scl,mode,[$14] ' 1/5 BIAS , 130Hz/5v
pause 10

'CONTRAST SET------------pag 37 datasheet
I2CWRITE sda, scl,mode,[$7F]
pause 10

'POWER/ICON/CONTRAST------pag 36 datasheet
I2CWRITE sda, scl,mode,[$5B] 'ICON=ON, BON = OFF , contrast $03
pause 10

'FOLLOWER CONTROL-------pag 37 datasheet
I2CWRITE sda, scl,mode,[$6F] 'FON=1 ..set is correct ??
pause 10

'DISPLAY ON------------- pag 29 datasheet
I2CWRITE sda, scl,mode,[$0E] 'display ON, cursor ON, blink OFF
pause 10

RS = 1
pause 500

I2CWRITE SDA,SCL,mode,["HELLO"] 'print on the first line

DaveC3
- 28th December 2014, 23:19
Try this, initalization based on an arduino sketch


'PIC 16F1824

#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG

OSCCON = %01101010 'sets the internal oscillator to 4Mhz

TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
WPUA = %00000000
WPUC = %00000011

PORTA = 0
PORTC = 0

SCL VAR PORTC.0
SDA var PORTC.1
RS var PORTC.2
symbol mode = $7C

pause 100
RS = 0
'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)

'=============Initializing by Instruction==========pag 39 datasheet


I2CWRITE PORTC.1, PORTC.0,$7C,[$00] 'send command to display

'FUNCTION SET 0 and 1 ------------pag 30 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
pause 10

I2CWRITE PORTC.1, PORTC.0,$7C,[$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
pause 10



'INTERNAL OSC------------pag 35 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$14] ' 1/5 BIAS , 130Hz/5v


'CONTRAST SET------------pag 37 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$73]


'POWER/ICON/CONTRAST------pag 36 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$5E] 'ICON=ON, BON = OFF , contrast $03


'FOLLOWER CONTROL-------pag 37 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$6D] 'FON=1 ..set is correct ??
pause 10

'DISPLAY ON------------- pag 29 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$0C] 'display ON, cursor ON, blink OFF



'CLEAR LCD --------------pag 28 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$01]


'ENTRY MODE SET----------
I2CWRITE PORTC.1, PORTC.0,$7C,[$06] 'cursor/blink moves to right and DDRAM address is increased by 1.


RS = 1
pause 500

I2CWRITE PORTC.1,PORTC.0,$7C,["HELLO"] 'print on the first line [ I am not sure this line will work]



Can you include a high res picture of your display?

DaveC3
- 29th December 2014, 02:51
try this


'PIC 16F1824

#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG

OSCCON = %01101010 'sets the internal oscillator to 4Mhz

TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
WPUA = %00000000
WPUC = %00000011

PORTA = 0
PORTC = 0

SCL VAR PORTC.0
SDA var PORTC.1
RS var PORTC.2
symbol mode = $7C

pause 100
RS = 0
'OPF1 = 0 ; OPF2 = 0 . => BON=0, FON=1. => Vout=Vin (pag50 datasheet)

'=============Initializing by Instruction==========pag 39 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$78] 'slave

I2CWRITE PORTC.1, PORTC.0,$7C,[$00] 'send command to display

'FUNCTION SET 0 and 1 ------------pag 30 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
pause 10

I2CWRITE PORTC.1, PORTC.0,$7C,[$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
pause 10



'INTERNAL OSC------------pag 35 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$14] ' 1/5 BIAS , 130Hz/5v


'CONTRAST SET------------pag 37 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$73]


'POWER/ICON/CONTRAST------pag 36 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$5E] 'ICON=ON, BON = OFF , contrast $03


'FOLLOWER CONTROL-------pag 37 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$6D] 'FON=1 ..set is correct ??
pause 10

'DISPLAY ON------------- pag 29 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$0C] 'display ON, cursor ON, blink OFF



'CLEAR LCD --------------pag 28 datasheet
I2CWRITE PORTC.1, PORTC.0,$7C,[$01]


'ENTRY MODE SET----------
I2CWRITE PORTC.1, PORTC.0,$7C,[$06] 'cursor/blink moves to right and DDRAM address is increased by 1.


RS = 1
pause 500
I2CWRITE PORTC.1, PORTC.0,$7C,[$78] 'slave

I2CWRITE PORTC.1, PORTC.0,$7C,[$40] 'Write to display RAM
I2CWRITE PORTC.1,PORTC.0,$7C,["HELLO"] 'print on the first line [ I am not sure this line will work]
end

DaveC3
- 29th December 2014, 14:34
or try this,


#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG
OSCCON = %01101010 'sets the internal oscillator to 4Mhz

TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
SCL VAR PORTC.0
SDA var PORTC.1
Reset var PORTC.2 'could tie reset pin to vdd through 10K resistor


pause 100
HIGH Reset
'OPF1 = 0
goto StartProgram
'************************************************* *******************************
'=============Initializing LCD==========
ST7036Init:



'FUNCTION SET 0 and 1 ------------pag 30 datasheet

I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38] ' Function set - 8 bit, 2 line display 5x8, inst table 0
pause 10

I2CWRITE PORTC.1, PORTC.0,$78,[$00,$39] ' Function set - 8 bit, 2 line display 5x8, inst table 1
pause 10

I2CWRITE PORTC.1, PORTC.0,$78,[$00,$14,$73,$5E,$6D,$0C,$01,$06] '



Return
'************************************************* *******************************



startProgram:
gosub ST7036Init
I2CWRITE PORTC.1, PORTC.0,$78,[$40,$48,$65,$6c,$6c,$6f] ' Hello

IdleLoop:
' could blink an led here
goto Idleloop

midali
- 30th December 2014, 10:44
1000 x thx Dave for your help!
I tried all your suggestions, but nothing on display. Also I changed 3 lcds for test ,I tried another ways to initialise, but no succes.
I can make a photo at high resolution with LCD, but is only light, nothing else.
Its possible that LCD init is well, but problems come from contrast?
How I can make a loop with set contrast with values from $00 to $FF ?
Note: the LCD Bias must set to 1/5

Demon
- 30th December 2014, 12:49
On my lcd, I adjust contrast with the potentiometer on pin V0.

Robert

DaveC3
- 30th December 2014, 13:38
Without the LCD data sheet I don't think I can help ay more. Looking at the controller data sheet does not tell the whole story. There are different interfaces and component combinations for different VDD voltages and LCD manufactures. Where did you buy this LCD?

Dave

midali
- 30th December 2014, 17:19
Without the LCD data sheet I don't think I can help ay more. Looking at the controller data sheet does not tell the whole story. There are different interfaces and component combinations for different VDD voltages and LCD manufactures. Where did you buy this LCD?

Dave
You are right Dave !

All LCD's was a gift for me from a friend. He gave me a printed paper with sumary of LCD(7pins):
- Display Type : TM202SIFSUGWA
- LCD OPERATING VOLTAGE : 4.8V
- VDD : 5V
- DRIVE METHOD : 1/16 DUTY ; 1/5 BIAS
- CONTROLLER : ST7036i
- pinouts, tolerance, etc

Really on boards I found 3 LCDs with different serials, but the boards are same, with the same functions. Actually I work on TM202SGFSGWA-B-1A . On internet I dont find a datasheet for them. I suppose that all LCDs with ST7036 controllers have the same init. The serials depending from manufacturers.

The LCD's are mounted on a working factory boards. I desolder the LCD from motherboard for test...also I make a test on a LCD directly on board ( of course that I cuted the tracks from sda, scl and reset pins for separate of rest components board) because I want to be sure that LCD was not destroied from desoldering. Any code I wrote in pic, I tested with potentiometer divider , with V0 short with Vdd.

I see in datasheet that contrast can be configured from registry(case V0 short with Vdd) or from external resistors divider.

Also I have LCDs with 8 pins but I have not any information about them....I have a information only from a serial printed on back LCD side(TM202TCCWUGWA)...here I suppose that have a 7032 controller, but is no important at this time.

Again thx for your help !

Demon
- 30th December 2014, 21:15
I think the LCDs that googled up for TM202 were Tienma. None of them were TM202T or S. It looks like these are custom made, specs could be anything.

I suggest contacting Tienma and asking for a datasheet.

Robert

DaveC3
- 30th December 2014, 23:46
As an outside chance change your pullup resistors to 4.7K, I have never used 1k. The contrast is set in the initialization of the display. I do not think you can change it on the fly.
And lastly give this a try


'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : Dave Cutliff *
'* Notice : Copyright (c) 2014 Use at your own risk *
'* : All Rights Reserved *
'* Date : 12/29/2014 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG
OSCCON = %01101010 'sets the internal oscillator to 4Mhz

TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
SCL VAR PORTC.0
SDA var PORTC.1
Reset var PORTC.2 'could tie reset pin to vdd through 10K resistor


pause 100
HIGH Reset
'OPF1 = 0
goto StartProgram
'************************************************* *******************************
'=============Initializing LCD==========
ST7036Init:





I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38, $39,$14,$79,$50,$6C,$0C,$01,$06] '



Return
'************************************************* *******************************



startProgram:
gosub ST7036Init
I2CWRITE PORTC.1, PORTC.0,$78,[$40,$48,$65,$6c,$6c,$6f] ' Hello

IdleLoop:
' could blink an led here
goto Idleloop

Demon
- 31st December 2014, 01:35
As an outside chance change your pullup resistors to 4.7K, I have never used 1k. ...

Yup, from the manual:

The I2C clock and data lines should be pulled up to Vcc with a 4.7K

Could this be an issue?

Transfer on the I2C bus can be paused by the receiving device by its holding the clock line low (not supported on 12-bit core PIC MCUs). To enable this the following DEFINE should be added to the program:

DEFINE I2C_HOLD 1

Robert


EDIT: I would try one last thing with Dave's code, add PAUSE 250 before every write to the LCD, just to eliminate that possibility.

midali
- 31st December 2014, 07:29
Dave, with your last example code nothing help. I insert pause 250 between instructions and appear something like this : "ell o Hello " on LCD, but a very low contrast.i have not enough free time to change resistors from 1k to 4k7 . So, Its a good way! Thx Dave and Robert!

Very strange, I tried quickly some variants to display a text without succes. I wrote again working code and again nothing on LCD :)
So,now I must go with my family to party and "next year" I'm back to try.

Again 1000x thx and Happy New Year to all forum members !

DaveC3
- 31st December 2014, 15:40
If you saw something on the display we are getting close. When you get a chance post the code where you saw "ell o Hello "

Here is an initialization for a 5v display data sheet simular to yours.



INITIALIZE: (5V)
MOV I2C_CONTROL,#00H ;WRITE COMMAND
MOV I2C_DATA,#38H ;Function Set
LCALL WRITE_CODE
MOV I2C_CONTROL,#00H ;WRITE COMMAND
MOV I2C_DATA,#39H ;Function Set
LCALL WRITE_CODE
MOV I2C_DATA,#14H ;Internal OSC frequency
LCALL WRITE_CODE
MOV I2C_DATA,#79H ;Contrast set
LCALL WRITE_CODE
MOV I2C_DATA,#50H ;Power/ICON control/Contrast set
LCALL WRITE_CODE
MOV I2C_DATA,#6CH ;Follower control
LCALL WRITE_CODE
MOV I2C_DATA,#0CH ;Display ON/OFF
LCALL WRITE_CODE
MOV I2C_DATA,#01H ;Clear Display
LCALL WRITE_CODE



Based on this information try to change your code to


ST7036Init:





I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38]
PAUSE 10
I2CWRITE PORTC.1, PORTC.0,$78,[$00, $39,$14,$79,$50,$6C,$0C,$01,$06] '



Return

midali
- 1st January 2015, 10:09
Working first code :

'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : Dave Cutliff *
'* Notice : Copyright (c) 2014 Use at your own risk *
'* : All Rights Reserved *
'* Date : 12/29/2014 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG
OSCCON = %01101010 'sets the internal oscillator to 4Mhz
DEFINE I2C_HOLD 1
TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
SCL VAR PORTC.0
SDA var PORTC.1
Reset var PORTC.2 'could tie reset pin to vdd through 10K resistor

pause 1000
HIGH Reset
goto StartProgram
'************************************************* *******************************
'=============Initializing LCD==========
ST7036Init:
I2CWRITE PORTC.1, PORTC.0,$78,[$00]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$38]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$39]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$14]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$79]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$50]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$6C]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$0C]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$01]
pause 250
I2CWRITE PORTC.1, PORTC.0,$78,[$06]
pause 250
Return
'************************************************* *******************************
startProgram:
gosub ST7036Init
I2CWRITE PORTC.1, PORTC.0,$78,[$40,$48,$65,$6c,$6c,$6f] ' Hello

IdleLoop:
' could blink an led here
goto Idleloop

Very strange whats happened: I wrote hex file , on LCD apppeared something like this :"ell o Hello ". I writed the file again, with the same hex file , on the same test board, without any changes ....and nothing on LCD! I tried many times...I discharged a capacitors from Vcc, I disconected the power supply 30 min, I turn ON again ...nothing!
So, today I have free time to study . I'll try next Dave's suggestion.

Thx for your patience ,Dave!!

midali
- 1st January 2015, 11:04
If you saw something on the display we are getting close. When you get a chance post the code where you saw "ell o Hello "

Here is an initialization for a 5v display data sheet simular to yours.



INITIALIZE: (5V)
MOV I2C_CONTROL,#00H ;WRITE COMMAND
MOV I2C_DATA,#38H ;Function Set
LCALL WRITE_CODE
MOV I2C_CONTROL,#00H ;WRITE COMMAND
MOV I2C_DATA,#39H ;Function Set
LCALL WRITE_CODE
MOV I2C_DATA,#14H ;Internal OSC frequency
LCALL WRITE_CODE
MOV I2C_DATA,#79H ;Contrast set
LCALL WRITE_CODE
MOV I2C_DATA,#50H ;Power/ICON control/Contrast set
LCALL WRITE_CODE
MOV I2C_DATA,#6CH ;Follower control
LCALL WRITE_CODE
MOV I2C_DATA,#0CH ;Display ON/OFF
LCALL WRITE_CODE
MOV I2C_DATA,#01H ;Clear Display
LCALL WRITE_CODE



Based on this information try to change your code to


ST7036Init:





I2CWRITE PORTC.1, PORTC.0,$78,[$00,$38]
PAUSE 10
I2CWRITE PORTC.1, PORTC.0,$78,[$00, $39,$14,$79,$50,$6C,$0C,$01,$06] '



Return




I tried ...
if I write the PIC and turn ON the board with Vcc = 3,6V I see on LCD this:
7621
...then I move the Vcc to 5V, on LCD appear :
7622
In this case I can set a contrast from 5k potentiometer on V0 LCD pin, but I see only full dots.

If I write the PIC and turn ON the board with Vcc = 5v, I see nothing on LCD. No effect if I down the voltage to 3,6V !

midali
- 1st January 2015, 12:01
'************************************************* *******************************
IdleLoop:
I2CWRITE PORTC.1, PORTC.0,$78,[$00, $39,$14,$79]
pause 250
goto Idleloop
end[/CODE]

With this line is nothing on display. One time appeared undefinited characters, who move to right one by one.

Identically, in this case I run initially Vcc at 3,6V and after few seconds I changed to 5v.

DaveC3
- 1st January 2015, 14:32
In the above loop you are writing commands over and over again. I would not expect anything to display. I have to assume the supply to this display needs to be 5v (according to the paper you received from your friend). The connections should look like this with 5v7623

Also change the address to $7C again according to the data sheet i found.



I2C interface
It just only could write Data or Instruction to ST7032 by the IIC Interface.
It could not read Data or Instruction from ST7032 (except Acknowledge signal).
SCL: serial clock input
SDA: serial data input
Slaver address could only set to 0111110, no other slaver address could be set



I found this data sheet at http://www.farnell.com/datasheets/1669635.pdf

The pinouts are the same as your display



'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : Dave Cutliff *
'* Notice : Copyright (c) 2014 Use at your own risk *
'* : All Rights Reserved *
'* Date : 12/29/2014 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG
OSCCON = %01101010 'sets the internal oscillator to 4Mhz

TRISA = %00000000
TRISC = %00000000
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
SCL VAR PORTC.0
SDA var PORTC.1
Reset var PORTC.2 'could tie reset pin to vdd through 10K resistor


pause 100
HIGH Reset
'OPF1 = 0
goto StartProgram
'************************************************* *******************************
'=============Initializing LCD==========
ST7036Init:






I2CWRITE PORTC.1, PORTC.0,$7C,[$00,$38]
PAUSE 10
I2CWRITE PORTC.1, PORTC.0,$7C,[$00, $39,$14,$79,$50,$6C,$0C,$01,$06] '



Return
'************************************************* *******************************



startProgram:
gosub ST7036Init
I2CWRITE PORTC.1, PORTC.0,$7C,[$40,$48,$65,$6c,$6c,$6f] ' Hello

IdleLoop:
' could blink an led here
goto Idleloop



give the above a try, that a look at the data sheet.

Good luck

Dave

midali
- 2nd January 2015, 10:54
Incredible but real !
Don't work!
I tried initializing by internal reset circuit, also I tried initialising by instructions...nothing on LCD!
One time appeared "@ello" ...i disconected the Vcc, reconect and again blank lcd.
Its spent free time for all, so I decided that I'll buy a LCD's with 7036i and 7032i controller and I'll test . After its works, I'll back to my LCD.I want to be sure that is 7036 or 7032 controller on my LCD's!
I'll be back after I'll buy the LCD's .

Thank you very much Dave for patience and for your help!!

DaveC3
- 2nd January 2015, 13:32
No problem, sorry it does not wok for you. Did you try 4.7K pullups?

Take care
Dave

midali
- 2nd January 2015, 17:50
Each time I verified with 4k7 and 1k. I made 2 different boards for tests.
I found on market LCD with 7036i controller with own datasheet. I hope that in 2 weeks I'll receive it.

midali
- 28th December 2015, 15:42
I'm back after exactly 1 year. :)
I changed the 16LF1824 with 16F1503 and now LCD is working !
Many thx to Dave and Robert !

Now I need again a your help. How i can display a variable ? (for example, x from my code )

Working code:


DEFINE I2C_HOLD 1
TRISA = 000000
TRISC = 000000
ANSELA = 000000
ANSELC = 000000
OPTION_REG.7 = 0

SCL VAR PORTC.0
SDA var PORTC.1
Reset var PORTC.2
x var byte :x=12
com con $78

pause 100
HIGH Reset

goto StartProgram
'************************************************* *******************************
'=============Initializing LCD==========
ST7036Init:
I2CWRITE SDA,SCL,com,[$00,$38]'function set
pause 1
I2CWRITE SDA,SCL,com,[$00,$39]'function set
pause 1
I2CWRITE SDA,SCL,com,[$00,$14]'internal OSC
pause 1
I2CWRITE SDA,SCL,com,[$00,$6A]'follower control
pause 1
I2CWRITE SDA,SCL,com,[$00,$0C]'display on/off
pause 1
I2CWRITE SDA,SCL,com,[$00,$01]'clear display
pause 1
I2CWRITE SDA,SCL,com,[$00,$06]'entry mode set
pause 1
Return
'************************************************* *******************************
startProgram:
gosub ST7036Init
I2CWRITE SDA, SCL,com,$40,"hello"

Main:
'program
goto Main

Heckler
- 29th December 2015, 15:45
midali,


Now I need again a your help. How i can display a variable ? (for example, x from my code )


that should be EASY!!

in your example above just replace the "hello" with X (no quotes this time)
you might need to choose how you want X to display... in the manual you should find where you can use modifiers like DEC for a decimal value or HEX for the hex value, etc.

midali
- 29th December 2015, 17:35
Nothing on LCD: I2CWRITE SDA, SCL,com,$40, x
In ST7036 manual I not found how I can display a decimal number.

richard
- 29th December 2015, 20:41
I2CWRITE SDA, SCL,com,$40,"hello"

looks like incorrect syntax , should be like this


I2CWRITE SDA, SCL,com,[$40,"hello"]

to display x (assume pbp3)



buff var byte[16]

ARRAYWRITE buff,[dec3 x]
I2CWRITE SDA, SCL,com,[$40,str buff"]

[/CODE]

Heckler
- 29th December 2015, 20:49
Now that I think about it you probably will need to include a "Modifer" before your variable.

Otherwise your LCD display may think the number is some sort of control character or it may be a non displayable character.


from the PBP manual...



An assortment of string-formatting modifiers is available for use within the item list
of this command. These modifiers can be used to format string output that includes
numeric values converted from variables:
Output Modifiers for Formatting Strings
Modifier Operation
{I}{S}DEC{1..10} Send decimal digits
{I}{S}BIN{1..32} Send binary digits
{I}{S}HEX{1..8} Send hexadecimal digits
REP char\count Send character c repeated n
times
STR ArrayVar{\count} Send string of n characters
See section 2.11 for details on string-formatting modifiers.

midali
- 29th December 2015, 21:36
Now display the x value on LCD , like "hello 012" .

In main loop, the text is scrolling from right to left on 2 lines.


SCL VAR PORTC.0
SDA var PORTC.1
Reset var PORTC.2
x var byte :x=12
com con $78
buff var byte[16]
pause 100
HIGH Reset

goto StartProgram
'************************************************* *******************************
'=============Initializing LCD==========
ST7036Init:
I2CWRITE SDA,SCL,com,[$00,$38]'function set
pause 1
I2CWRITE SDA,SCL,com,[$00,$39]'function set
pause 1
I2CWRITE SDA,SCL,com,[$00,$14]'internal OSC
pause 1
I2CWRITE SDA,SCL,com,[$00,$6A]'follower control
pause 1
I2CWRITE SDA,SCL,com,[$00,$0C]'display on/off
pause 1
here:
I2CWRITE SDA,SCL,com,[$00,$01]'clear display
pause 1
I2CWRITE SDA,SCL,com,[$00,$06]'entry mode set
pause 1
Return
'************************************************* *******************************
startProgram:
ARRAYWRITE buff,[dec3 x]

gosub ST7036Init

I2CWRITE SDA, SCL,com,[$40,"hello ",str buff\x]

Main:
'I2CWRITE SDA, SCL,com,[$40,"hello ",str buff\x]
pause 1000
goto Main

Thank you very much for your help!

richard
- 29th December 2015, 23:28
I2CWRITE SDA, SCL,com,[$40,"hello ",str buff\x]

is incorrect




I2CWRITE SDA, SCL,com,[$40,"hello ",str buff] or
I2CWRITE SDA, SCL,com,[$40,"hello ",str buff\3 ]

is whats required.


The "\x" ( length specifier) if used is the number or chr's in the the string {buff in this case } to send (12 {the value of x} is inappropriate), a null terminated string (as created by arraywrite ) needs no length parameter to be specified if you wish to send the entire string

midali
- 30th December 2015, 09:21
Now I understand arrays variable. Thank you for your patience and explanation!

zoltanh
- 8th January 2021, 22:52
Hi,

I am just curious. Did you manage to run LCD with the pinout from MIDAS? I mean the pinout you mentioned at beginning of this thread.