PDA

View Full Version : LCD and HSEROUT do not mix well ?



Johan
- 15th November 2008, 10:28
I tried to display decimal value to LCD, it works.

How to display the value to LCD while sending the value with HSEROUT ?
Everytime I enable the HSEROUT command , the LCD do not display anything , not even the "HELLO" at the beginning
If the HSEROUT line is disabled, the LCD works again

Please take a look at my code below. Thanks





'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 14/11/2008 *
'* Version : 1.0 *
'* Notes : 16F88 20 Mhz *
'* : PBP 2.50b MPASM *
'************************************************* ***************


ASM
__config _CONFIG1, _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_ALL & _CCP1_RB3
__config _CONFIG2, _IESO_OFF & _FCMEN_OFF

endasm

define osc 20
define hser_rcsta 90h
define hser_txsta 20h
define hser_baud 9600
define hser_spbrg 25
DEFINE HSER_CLROERR 1

DEFINE LCD_DREG PORTB ' LCD data port
DEFINE LCD_DBIT 0 ' LCD data starting bit
DEFINE LCD_RSREG PORTA ' LCD register select port
DEFINE LCD_RSBIT 3 ' LCD register select bit
DEFINE LCD_EREG PORTA ' LCD enable port
DEFINE LCD_EBIT 4 ' LCD enable bit
DEFINE LCD_BITS 4 ' LCD data bus size
DEFINE LCD_LINES 2 ' Number lines on LCD
DEFINE LCD_COMMANDUS 2000 ' Command delay time in us
DEFINE LCD_DATAUS 50 ' Data delay time in us


CLEAR
TRISA = %00000000
TRISB = %00000000
ANSEL = %00000000
value var byte

lcdout $FE,1
start:

LCDOUT $FE,1, " Hello"
pause 50
for value = 1 to 255
LCDout $FE,$C0, dec value
pause 50
;hserout [0,dec value] ; IF THIS LINE IS ENABLED, LCD DOESN NOT DISPLAY ANYTHING
pause 50
next value

pause 5000

goto start

mat janssen
- 15th November 2008, 12:35
Try to put a pause of 1 sec. yust before your programm starts.
The display must be initialised. And that kosts time.
The instruction is faster then the display initialisation.
Between
value var byte
(here)
lcdout $FE,1

you put a pause ot 1 sec.

mister_e
- 15th November 2008, 20:57
If i remember correctly, lower bits of PORTB, ( PORTB.2 ) is also multiplexed with RX of the USART. And i don't remember if this PIC allow you to disable the RX part, so my guess would be...

for value = 1 to 255
RCSTA=0 ' Disable USART
TRISB.2=0
pause 25
LCDout $FE,$C0, dec value
pause 25
RCSTA=$90 ' enable USART
pause 25
hserout [0,dec value] ; IF THIS LINE IS ENABLED, LCD DOESN NOT DISPLAY ANYTHING
pause 50
next value

sure enough there's few unecessary delay up here... not sure if this will help and work at all using the above... Maybe a good situation to use SEROUT/SEROUT2/DEBUG?

PS: Make sure of your DEFINES, must all be in UPPERCASE, unless, it may not work.

Charles Linquis
- 15th November 2008, 23:19
Mister E is right, the DEFINES must be in upper-case, and are not checked by the compiler, which means there are no error messages if you don't enter them correctly - they just don't work.

Also, you are using PORTA.4 as your LCD ENABLE. You MUST put a pull-up on this port if you are going to use it as an output.

Archangel
- 16th November 2008, 07:12
If i remember correctly, lower bits of PORTB, ( PORTB.2 ) is also multiplexed with RX of the USART. And i don't remember if this PIC allow you to disable the RX part, so my guess would be...

for value = 1 to 255
RCSTA=0 ' Disable USART
TRISB.2=0
pause 25
LCDout $FE,$C0, dec value
pause 25
RCSTA=$90 ' enable USART
pause 25
hserout [0,dec value] ; IF THIS LINE IS ENABLED, LCD DOESN NOT DISPLAY ANYTHING
pause 50
next value

sure enough there's few unecessary delay up here... not sure if this will help and work at all using the above... Maybe a good situation to use SEROUT/SEROUT2/DEBUG?

PS: Make sure of your DEFINES, must all be in UPPERCASE, unless, it may not work.
Hi Steve, A little time sharing going on in there, cool.

Johan
- 17th November 2008, 11:20
Thank you for your help :)
I modifies as Steve's suggestion, it works now

Actually I do not require the RX part, is there any way permanently disable the RX part ( to save 2x pause 25 ) ?

mister_e
- 17th November 2008, 16:38
Not sure you require them anyways... seems there's no way to use only the Transmitter section. So, or you change HSEROUT to DEBUG, or you add the above in your code.

Probably I would use the DEBUG route myself.