Simple serial debug script


Closed Thread
Results 1 to 3 of 3
  1. #1
    barkerben's Avatar
    barkerben Guest

    Default Simple serial debug script

    Hi - I have the following debug code for software serial output. Unfortunately, I seem to receive garbage, albeit consistent garbage, at the
    PC. This ixample gives me underscores only at the PC end for instance.

    It seems so simple- any glaring errors? Could it be that I'm using the hardware serial pins, even though I'm actually using them for software serial...?

    Cheers,

    Ben

    <code>
    ' PicBasic program to demonstrate operation of an LCD in 4-bit mode
    '
    ' LCD should be connected as follows:
    ' LCD PIC
    ' DB4 PortA.0
    ' DB5 PortA.1
    ' DB6 PortA.2
    ' DB7 PortA.3
    ' RS PortA.4 (add 4.7K pullup resistor to 5 volts)
    ' E PortB.3
    ' RW Ground
    ' Vdd 5 volts
    ' Vss Ground
    ' Vo 20K potentiometer (or ground)
    ' DB0-3 No connect

    Include "modedefs.bas"

    ' Set LCD Enable port
    DEFINE LCD_EREG PORTB

    ' Set LCD Enable bit
    DEFINE LCD_EBIT 5


    PORTB.7=0 ' Reset GPS Module
    Pause 500 ' Wait for LCD to startup
    PORTB.7=1 ' Reset GPS Module


    loop: Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "Hello" ' Display Hello
    SEROUT PORTB.1,N300,["A"]
    SEROUT PORTB.2,N300,["B"]
    Pause 500 ' Wait .5 second

    Lcdout $fe, 1 ' Clear LCD screen
    Lcdout "World"
    Pause 500 ' Wait .5 second


    Goto loop ' Do it forever

    </code>

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    might not help, but im sure this line " DEFINE LCD_EBIT 5" should be "DEFINE LCD_EBIT 3" (At least if uve got the lcd connected the way it says in those comment lines at the top)

  3. #3
    barkerben's Avatar
    barkerben Guest


    Did you find this post helpful? Yes | No

    Default

    Ah - The comments are a leftover from some code I scavenged. I believe that
    pin 3 port B is the default for the enable bit, but I had to change it.

    I did get the serial working - hope to try the LCD again in a day or so when I next get the chance...

    Ben

Similar Threads

  1. N-Bit_MATH
    By Darrel Taylor in forum Code Examples
    Replies: 38
    Last Post: - 16th December 2010, 14:48
  2. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  3. debug not working with MPASM assempler
    By santamaria in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th March 2009, 07:51
  4. Simple Serial Comms.
    By koossa in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd November 2007, 08:12
  5. Simple Serial communications
    By kitcat in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th July 2005, 19:42

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