LCD and HSEROUT do not mix well ?


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2007
    Posts
    56

    Default LCD and HSEROUT do not mix well ?

    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


    Code:
    '****************************************************************
    '*  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
    Last edited by Johan; - 15th November 2008 at 10:31.

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    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.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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...
    Code:
        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.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    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.
    Charles Linquist

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    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...
    Code:
        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.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Jun 2007
    Posts
    56


    Did you find this post helpful? Yes | No

    Default

    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 ) ?

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Is HSEROUT corrupting bit 7 ?????
    By Robert Wells in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd October 2008, 16:26
  2. HSEROUT to LCD with 16F887
    By menta in forum General
    Replies: 14
    Last Post: - 26th June 2008, 18:05
  3. lcd with Hserout and a max232 connections? help
    By flipper_md in forum Schematics
    Replies: 6
    Last Post: - 8th March 2008, 15:06
  4. DS1820 and 18f2550
    By rjones2102 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd October 2007, 18:11
  5. Controlling an 240x128 LCD Touchpanel Display
    By Vincent in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 7th June 2006, 23:36

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts