Learning how to use USART


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: Learning how to use USART

    There is an initialization process to get LCDs to come on line. It usually isn't needed, but I ran into an instance like yours where everything suggested it SHOULD work, but it didn't. One of the HD44780 LCD Data Sheets outlined an initialization process. Here is what I use:

    4-Wire
    Code:
    Init_LCD:
        RS = 0
    '    LCD = $20
        DB7 = 0
        DB6 = 0
        DB5 = 1
        DB4 = 0
            En = 1
            pauseus 10
            En = 0
            pause 5
    '    LCD = $20
        DB7 = 0
        DB6 = 0
        DB5 = 1
        DB4 = 0
            En = 1
            pauseus 10
            En = 0
            pauseus 160
    '    LCD = $20
        DB7 = 0
        DB6 = 0
        DB5 = 1
        DB4 = 0
            En = 1
            pauseus 10
            En = 0
            pauseus 160
        LCD = $28
            gosub Send
        LCD = $10
            gosub Send
        LCD = $0C
            gosub Send
        LCD = $06
            gosub Send
        LCD = 1
            gosub Send
            pause 1
        LCD = $80
            gosub Send
        RS = 1
        pause 1
    RETURN
    For 8-wire:
    Code:
    Init_LCD:
        low RS
        PORTB = $30
            high En
            pauseus 4
            low En
            pause 5
        PORTB = $30
            high En
            pauseus 4
            low En
            pauseus 160
        PORTB = $30
            high En
            pauseus 4
            low En
            pauseus 160
        PORTB = $38
            gosub Send
        PORTB = $10
            gosub Send
        PORTB = $0C
            gosub Send
        PORTB = $06
            gosub Send
        PORTB = 1
            gosub Send
            pause 1
        PORTB = $80
            gosub Send
        high RS
        pause 1 
    RETURN
    
    Send:
        high En
        pauseus 8
        low En
        pause 1
    return
    Maybe this will help.

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,680


    Did you find this post helpful? Yes | No

    Default Re: Learning how to use USART

    The blinking LED on the transmitting PIC is working, and the LCD on the receiving PIC is working, but I'm not seeing any numbers being displayed.
    given all things working display wise ,imho mike is leading you astray

    tx unit:-

    send = send + 1
    hserout [send]

    will send binary 0 to 9 , probably not the best idea but it is workable


    ps weird baud rate


    rx unit:-


    hserin [dec data_in]
    pause 5


    will never work

    1. its waiting for ascii numbers , the first non number will terminate routine
    2. pause 5 why it serves no purpose and can cause framing errors


    add this define
    DEFINE HSER_CLROERR 1 ' Clear overrun error upon execution of every HSERIN command


    rx unit:-
    lcdout $fe, $94, dec data_in

    if ok but it needs
    hserin [data_in] to match data types

    ps weird baud rate
    Last edited by richard; - 10th May 2018 at 05:09.
    Warning I'm not a teacher

Similar Threads

  1. remote code learning
    By Bruce in forum Code Examples
    Replies: 20
    Last Post: - 21st February 2021, 15:38
  2. Replies: 7
    Last Post: - 12th January 2018, 17:02
  3. USB Learning
    By ruijc in forum USB
    Replies: 19
    Last Post: - 26th July 2014, 21:09
  4. Learning Basic
    By bartman in forum General
    Replies: 14
    Last Post: - 19th November 2004, 00:45

Members who have read this thread : 2

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