PDA

View Full Version : 16f88 can't get lcd to work



nicjo
- 10th December 2006, 02:47
Hi all,

I've got a problem trying to display a simple message on an LCD using a PIC16F88. The problem, after much testing, seems to be the PAUSE command. It appears that the delay produced, even though in the code its 5sec, is much much much to small. So small infact that I think the LCD has little time initialise. The resulting text is very random both top and bottom lines.


DEFINE OSC 4 ' XT osc
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 3
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
' Set data delay time in us
DEFINE LCD_DATAUS 100

ANSEL=0
CMCON=7

GOSUB DELAY
Lcdout $fe, 1, "Hello" ' Display Hello
GOSUB DELAY
LCDOUT $FE,1,"John"
END
DELAY:PAUSE 5000
RETURN

I've tried everything including re-installing PBP/MCS. I've also compiled this code on a different machine;BUT, the LCD displays to quickly.

To confirm all is OK I compiled this code for the 16f628, all was fine, there was indeed a 5 sec delay. Back to the 16f88, tried another fresh chip, same as before. Can't be the chip..

I'm using PBP 2.47, MPLAB V7.31.




Help most appreciated.

John

nicjo
- 10th December 2006, 05:04
I've searched the forum on the 16f88, however, it revealed no real answers to my delema.

As far as I can tell the thing should work. I've set the fuses to:

__config _CONFIG1, _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF

Still can't see why the PAUSE command of 5 sec appears as though its in the order of msec. I'm thinking it could be the programmer?? K149-BC

skimask
- 10th December 2006, 06:08
Hi all,

I've got a problem trying to display a simple message on an LCD using a PIC16F88. The problem, after much testing, seems to be the PAUSE command. It appears that the delay produced, even though in the code its 5sec, is much much much to small. So small infact that I think the LCD has little time initialise. The resulting text is very random both top and bottom lines.


DEFINE OSC 4 ' XT osc
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 3
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
' Set data delay time in us
DEFINE LCD_DATAUS 100

ANSEL=0
CMCON=7

GOSUB DELAY
Lcdout $fe, 1, "Hello" ' Display Hello
GOSUB DELAY
LCDOUT $FE,1,"John"
END


DELAY:PAUSE 5000 <---------------

DELAY:
PAUSE 5000 <----- on a seperate line
I don't know why it should make a difference. Ya never know...




RETURN

I've tried everything including re-installing PBP/MCS. I've also compiled this code on a different machine;BUT, the LCD displays to quickly.

To confirm all is OK I compiled this code for the 16f628, all was fine, there was indeed a 5 sec delay. Back to the 16f88, tried another fresh chip, same as before. Can't be the chip..

I'm using PBP 2.47, MPLAB V7.31.




Help most appreciated.

John




See above......
JDG

nicjo
- 10th December 2006, 07:41
Thanks. I'm pretty sure that I've tried that. Code may have been slightly differnent but resulted in a new line for pause.

scatching me head...

mister_e
- 10th December 2006, 17:44
try....



PAUSE 2000
Lcdout $fe, 1, "Hello" ' Display Hello
Pause 2000
LCDOUT $FE,1,"John"
Spin: goto Spin


if it doesn't work, you may need to double check your hardware, make sure your programmer program the config fuses, and make sure your MCLR pin is not floating.

usual... 0.1uF cap close to the PIC, LCD R/W pin to GND and so on

In general the HS_OSC fuse may work with 4MHZ crystal but also try with XT_OSC to see if it make any difference.

savnik
- 10th December 2006, 20:29
try this


PAUSE 500

loop:

Lcdout $fe, 1,"Hello" ' Display Hello
Pause 2000
Lcdout $fe, 1,"John"
Pause 2000
goto loop

Archangel
- 11th December 2006, 21:59
Hi John,
Try this, I couldn't get the config fuses right for mpasm, but I was able to get them right for the default assembler. it should work :) keyword should.
JS




@ DEVICE MCLR_OFF, XT_OSC, WDT_OFF, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF
DEFINE OSC 4 ' XT osc
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 3
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
' Set data delay time in us
DEFINE LCD_DATAUS 100

TRISB=%00000000 ' all portb to output
TRISA=%00000000 ' all porta to output
ADCON1 = 7 ' or ADCON1 = %00000111 'Disable A/D converter
ANSEL=%00000000 ' set all analog pins to digital
CMCON=7
main
pause 2000
Lcdout $fe, 1, "Hello" ' Display Hello
pause 1000
LCDOUT $FE,1,"John"
goto main
END

mister_e
- 11th December 2006, 22:04
Joe
The MPASM config fuses are in the p16f88.inc file in the Microchip\MPASM suite folder



_CONFIG1 EQU H'2007'
_CONFIG2 EQU H'2008'

;Configuration Byte 1 Options
_CP_ALL EQU H'1FFF'
_CP_OFF EQU H'3FFF'
_CCP1_RB0 EQU H'3FFF'
_CCP1_RB3 EQU H'2FFF'
_DEBUG_OFF EQU H'3FFF'
_DEBUG_ON EQU H'37FF'
_WRT_PROTECT_OFF EQU H'3FFF' ;No program memory write protection
_WRT_PROTECT_256 EQU H'3DFF' ;First 256 program memory protected
_WRT_PROTECT_2048 EQU H'3BFF' ;First 2048 program memory protected
_WRT_PROTECT_ALL EQU H'39FF' ;All of program memory protected
_CPD_ON EQU H'3EFF'
_CPD_OFF EQU H'3FFF'
_LVP_ON EQU H'3FFF'
_LVP_OFF EQU H'3F7F'
_BODEN_ON EQU H'3FFF'
_BODEN_OFF EQU H'3FBF'
_MCLR_ON EQU H'3FFF'
_MCLR_OFF EQU H'3FDF'
_PWRTE_OFF EQU H'3FFF'
_PWRTE_ON EQU H'3FF7'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FFB'
_EXTRC_CLKOUT EQU H'3FFF'
_EXTRC_IO EQU H'3FFE'
_INTRC_CLKOUT EQU H'3FFD'
_INTRC_IO EQU H'3FFC'
_EXTCLK EQU H'3FEF'
_HS_OSC EQU H'3FEE'
_XT_OSC EQU H'3FED'
_LP_OSC EQU H'3FEC'

;Configuration Byte 2 Options
_IESO_ON EQU H'3FFF'
_IESO_OFF EQU H'3FFD'
_FCMEN_ON EQU H'3FFF'
_FCMEN_OFF EQU H'3FFE'

AND NEVER EVER END A PROGRAM WITH A SINGLE END STATEMENT... use STOP OR an endless loop

Here we don't know if the user use an external or want to use the internal OSC...

Archangel
- 12th December 2006, 07:49
Joe . . .

AND NEVER EVER END A PROGRAM WITH A SINGLE <h1>END</h1> STATEMENT... use STOP OR an endless loop

...
Sorry about that mister_e, it got by me on the fourth paste, I had installed a goto main and then did a repaste and, oops left it out. As for mpasm config fuses . . . I kept getting errors using this format
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _BODEN_ON but not this exact code. I have edited above post.
JS

mister_e
- 12th December 2006, 14:58
Yeah F88 is a bit like some 18F, try something around those bellow


'
' Pic Configuration
' =================
' Program Configuration Register 1
@ __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_ON & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO

' Program Configuration Register 2
@ __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF

Archangel
- 12th December 2006, 19:42
Hi Mister_e,
The 16F88 seems to be extra labor intensive and not suitable for newbies, as it has so many registers that require you to set and other little quirks, there are several open posts this month by people (like myself) who are a little short on experience, that are having trouble with this device. I think they would do better with a 16F628a / 648a or 16F876 / 877 etc. At least until they get their sealegs. :)

keithdoxey
- 12th December 2006, 20:26
Hi Mister_e,
The 16F88 seems to be extra labor intensive and not suitable for newbies, as it has so many registers that require you to set and other little quirks, there are several open posts this month by people (like myself) who are a little short on experience, that are having trouble with this device. I think they would do better with a 16F628a / 648a or 16F876 / 877 etc. At least until they get their sealegs. :)

To some extent that comment may be true but as the 16F88 is so versatile you can use it for many different projects so will quickly learn its quirks.

I was using 16F628 for 18pin projects and 16F877 for 40 pin projects.

I am now using 16F88 and 18F452.

My 40 pin project outgrew the capabilities of the 877 and my reason for getting started with the F88 was because it can be bootloaded. A real boon for developing code :)

mister_e
- 13th December 2006, 02:20
well well well... there's always a new device... so there's always a new challenge (sort of) or problem.

F88 is probably the new F628(a) for those doing the BIG JUMP from an F84(a). just do a search with 16F628, you'll be surprised how much time me and other repeat CMCON=7 :p

I also appreciate the F88 and it's like all firsts experience... the first time it doesn't work... You have to learn from it. and...read the datasheet A.K.A TFM (The Fabulous Manual)

I don't really have a favourite one... from 10F to 18F and some DsPIC when really needed.