PDA

View Full Version : 16f886 and LCDOUT



BLUEBILL
- 12th April 2011, 18:28
HI ALL. WONDERING IF ANYONE HAS EXPERIENCE WITH 16F886 AND LCD OUT. I'M USEING A LUMEX LCD PART NUMBER LCM S01602DTR/A.
MY CODE IS..
'*************
'************************************************* ***************
'Configuration Bits
@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF

@ __config _CONFIG2, _WRT_OFF

OSCCON = $71 'SET OSCILTOR TO INTERNAL 8 MHZ
DEFINE OSC 8

'------------------------------------------------------------------------------




'_________________________________________________ ____________________________

'INITIALIZE PORTS
'PORT A
ANSEL = 0 'PORT A DIGITAL
TRISA = %11111111 'PORT A ALL INPUT

'PORT B
ANSELH = %00000000 'PORT B DIGITAL
TRISB = %00000000 'PORT ALL OUTPUT
IOCB.0 = 0
CCP1CON = %00000000


'PORT C OUTPUTS
TRISC = %00001111 'PORTC 0-3 INPUT 4-7 OUTPUTS

'_________________________________________________ ___________________________

'SET LCD PARAMETERS
DEFINE LCD_DREG PORTB 'SET LCD DATA PORT
DEFINE LCD_DBIT 0 'SET STARTING LCD DATA BIT
DEFINE LCD_RSREG PORTB 'SET LCD REGISTER SELECT PORT
DEFINE LCD_RSBIT 4 'SET LCD REGISTER SELECT BIT
DEFINE LCD_EREG PORTB 'SET LCD ENABLE PORT
DEFINE LCD_EBIT 5 'SET LCD ENABLE BIT
define LCD_BITS 4 'SET TO 4 BIT
DEFINE LCD_LINES 2 'SET NUMBER OF LINES ON LCD

DEFINE LCD_COMMANDUS 1500 'SET COMMAND DELAY TIME IN US
DEFINE LCD_DATAUS 44 'SET DATA DELAY TIME IN US


'_________________________________________________ ____________________________

'DECLARE ALIAS'S

LED VAR PORTC.4 'LED on a 330 High is on


'_________________________________________________ ____________________________


'_________________________________________________ ____________________________

pause 1000
LCDOUT $FE,1
pause 1000
AGAIN:
LCDOUT $FE,1,"TO PLAYER"
LCDOUT $FE,$C0, "FROM PLAYER"

high led
pause 1000
low led
pause 1000
goto again

end

'''''''''''''
I'M CONCERNED THAT I MAY HAVE MISSED A REGISTER SETUP ON PORT B.
ANY INPUT WOULD BE APRECIATED.
THANKS,
BILL

Archangel
- 12th April 2011, 19:29
Hi BLUEBILL,
You might look at those comparators and SR latch settings , and sspcon. . .I don't know the power up state of them.
EDIT: Ok looks like sspcon affects PortC, CM2CON0,CM2CON1, CM2CON2, CM1CON0, somewhere in there I think.

rsocor01
- 13th April 2011, 03:18
BlueBill,

Do you see anything on the LCD? Are you using a contrast resistor? Also, I think you should change the line

IOCB.0 = 0

to

IOCB = 0

I don't know if it would make a difference, but you want to disable all the PORB On-Change-Interrupts bits instead of just one.

Robert

aerostar
- 13th April 2011, 07:23
"define LCD_BITS 4 'SET TO 4 BIT"


"define" should be "DEFINE" all your others were uppercase.

Manual states

These definitions must be in all upper case. If not, the compiler may not recognize them. No error message will be produced for DEFINEs the compiler does not recognize

rsocor01
- 13th April 2011, 08:47
"define LCD_BITS 4 'SET TO 4 BIT"


"define" should be "DEFINE" all your others were uppercase.

Manual states

These definitions must be in all upper case. If not, the compiler may not recognize them. No error message will be produced for DEFINEs the compiler does not recognize

Good catch!! Yes the DEFINE must be all in upper case as stated in the manual.

BLUEBILL
- 13th April 2011, 17:59
BlueBill,

Do you see anything on the LCD? Are you using a contrast resistor? Also, I think you should change the line

IOCB.0 = 0

to

IOCB = 0

I don't know if it would make a difference, but you want to disable all the PORB On-Change-Interrupts bits instead of just one.

Robert

Hi Robert.

The LCD is blank which leads me to think i'm not initializing it. I'm using a 20k variable contrast resistor. I made the change IOCB.0 =0 to IOCB = 0 with no change. I will keep experimenting and post my results.
Thanks again.

BLUEBILL
- 13th April 2011, 18:04
"define LCD_BITS 4 'SET TO 4 BIT"


"define" should be "DEFINE" all your others were uppercase.

Manual states

These definitions must be in all upper case. If not, the compiler may not recognize them. No error message will be produced for DEFINEs the compiler does not recognize

Sorry, Its cap in MicroCode Studio. It changed when I cut and pasted it.???

BLUEBILL
- 13th April 2011, 21:38
Hi BLUEBILL,
You might look at those comparators and SR latch settings , and sspcon. . .I don't know the power up state of them.
EDIT: Ok looks like sspcon affects PortC, CM2CON0,CM2CON1, CM2CON2, CM1CON0, somewhere in there I think.


Hi. I replied a couple times but I'm a bit of a novice when it comes to FORUMS.
I reviewed the registers and even cleared all applicable registers but still no luck.
I tried manualy initializing by seting portb outputs and strobing the E bit but no joy. Hope this reply works.

rsocor01
- 14th April 2011, 02:26
Hi Robert.

The LCD is blank which leads me to think i'm not initializing it. I'm using a 20k variable contrast resistor. I made the change IOCB.0 =0 to IOCB = 0 with no change. I will keep experimenting and post my results.
Thanks again.

Hmmm, I haven't worked with these LCD displays in a while, but I think 20k is too high. The way I do it is by using a 10k pot and I play with it (change values from 0 to 10k) to find the optimum value. Give it a try and let us know....

Robert

BLUEBILL
- 14th April 2011, 18:51
Hmmm, I haven't worked with these LCD displays in a while, but I think 20k is too high. The way I do it is by using a 10k pot and I play with it (change values from 0 to 10k) to find the optimum value. Give it a try and let us know....

Robert

Thanks Robert. It is my contrast setting. The LCD works and I'm a bit more educated regarding the special function registers of a 16f886. I did check the setting on an earlier date but had no idea that the supply voltage would be so low. 800mv on pin 3 displays fine. I didn't adjust that far down until your suggestion. Thanks again and thanks for everyones input.