Hyper Terminal Displaying Random Characters [PIC to PC via UART]


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2011
    Posts
    5

    Default Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    Hello everyone, this will be my first post.

    I am using PIC16F77A to connect to a PC via UART but hyperterminal displays only 3 types of characters each time i push the push button: 1 unknown character, a dot and a space. My initial output should be 0 then incremented by 1 each time the push button is pressed.

    Details:
    The language used is PIC Basic Pro, Complier: MicroCode Studio Version 4.0, Assembler: Microchip/mpasm suite, MPLAB IDE v8.66
    i used a uart to establish connection with a PC, Windows 7.

    Coding:
    INCLUDE “modedefs.bas” ‘ Serial communication mode definition file
    DEFINE OSC 20 ‘ Oscillator speed is set to 20MHz
    TRISB = %11111111
    TRISC = %10000000 ‘ RC.7 => USART RX pin set to input
    PortC = 0
    SPBRG = 25 ‘ Baud Rate = 9600

    ‘ Variable definition
    ‘ ===================

    DataOut var byte ‘ use to store TXREG content
    DataIn var byte ‘ use to store RCREG content
    DataIn = 0
    DataOut = 0

    mainloop:

    TXSTA = $24 ‘ enable transmit and SPBRGH = 1
    RCSTA = $90 ‘ Enable USART and continuous receive
    datain = DataOut ‘ Get data

    IF (PortB.7 = 1) THEN
    DataOut = DataIn + 1
    PAUSE 1000
    DataIn = DataOut
    TXREG = DataOut ‘ Transmit Data

    HIGH PortD.2
    PAUSE 2000
    LOW PortD.2

    ENDIF

    GOTO mainloop
    END

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default Re: Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    arson88 , If you want to see the characters received by the PC you should be running a terminal emulator program that will allow you to see the hex value of the received byte. I always use an old program called QMODEM which allows you to see any non printable characters like control characters. You do realize that there are more than 127 non printable characters that are possible to be sent via RS-232. I do not use Hyperterminal as the screen view is not big enough. There are a lot of other programs out there that will allow you to view the received byte value... Just look...

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Apr 2011
    Posts
    5

    Default Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    BTw, i am using http://www.cytron.com.my/viewProduct...7nn82zcVu7Ut0=
    , a USB to UART Converter.

  4. #4
    Join Date
    Apr 2011
    Posts
    5

    Default Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    nvm, i got the program right..
    INCLUDE “modedefs.bas” ‘ Serial communication mode definition file
    DEFINE OSC 20 ‘ Oscillator speed is set to 20MHz
    TRISB = %11111111
    TRISC = %10000000 ‘ RC.7 => USART RX pin set to input
    PortC = 0
    SPBRG = 129 ‘ Baud Rate = 9600
    ‘ Variable definition
    ‘ ===================

    count01 VAR BYTE ‘ variable to store TXREG content
    TXSTA = %00100100 ‘ Enable transmit and asynchronous mode
    RCSTA = %10010000 ‘ Enable serial port and continuous receive
    mainloop:
    IF (PortB.7 = 1) THEN
    FOR count01 = 1 TO 30
    PAUSE 2000
    TXREG = count01 + $30 ‘ Transmit Data
    HIGH PortD.2
    PAUSE 2000
    LOW PortD.2
    Next
    ENDIF
    GOTO mainloop
    END

    The result displayed in Hyperterminal:
    ASCII Character: 1, 2, 3, 4, 5, 6, 7, 8, 9, :, ; < until the 30th ASCII Character
    referred to page 203, PIC MCU With PICBasic [Chuck Hellebuyck]

    How do i convert the ASCII characters i received via Visal Basic 2010's serial port into integers?

    I used tiktakx's vb coding http://tiktakx.wordpress.com/2010/11...10/#comment-97

  5. #5

    Default Re: Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    hyper-term recieves the bytes and displays them as ASCII chars. The bytes with decimal 0-31, hex 0-1F are generally considered control chars and are mostly not printed or handled except for a few chars such as CR- carrage return, LF- line feed and HT- tab ----dec#s 13,10 & 9. There are no set rules on how a PC program will handle these control chars when recieved. You have to know how the program was made or its settings.
    To incriment a number to send to a PC use the # modifier on SEROUT which will send 1 char for 0 to 9, 2 chars for 10 to 99 and 3 chars for 100 to 255--- max value of 1 byte. You could write a routine to convert 1 byte to decimal digits but serout will do that with the modifiers.
    1 more thing, hyper-term can send bytes in the range of 0-31 dec using copy/paste from word-pad with chars coded by 'altX' eg(typing 4 then altX changes the 4(ascii 52) to dec 4(ascii 4)) which can be copy/pasted to hyper-term to send.

    don
    amgen

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    INCLUDE “modedefs.bas” ‘ Serial communication mode definition file
    Does nothing with the chip hardware serial port. Just takes up code space.
    BTw, i am using http://www.cytron.com.my/viewProduct...7nn82zcVu7Ut0=
    , a USB to UART Converter.
    But does it invert the signal?
    Dave
    Always wear safety glasses while programming.

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

    Default Re: Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    Hyper-terminal: I don't use it.
    RealTerm allows you the option of sending / receiving data either as RAW or ASCII.
    as for how do I . . . are you attempting to send to PIC or send to PC ? If issue is sending to PC put numbers inside quotes like "2468" and pic will send ascii, or precede numbers with DEC2468 and it will go RAW, or HEX9A4 for hex.

    As for Dave's (Mackracket) question, he is asking if the cytron thing inverts the serial data, as HSERin / out sends data TRUE with a pull up and PC likes INVERTED.
    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.

  8. #8
    Join Date
    May 2008
    Location
    Italy
    Posts
    825

    Default Re: Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    The OP needs to use a level converter as MAX 232 which also invert the signal.

    Cheers


    Al.
    All progress began with an idea

  9. #9
    Join Date
    May 2007
    Posts
    604

    Default Re: Hyper Terminal Displaying Random Characters [PIC to PC via UART]

    How are you doing with LPCXpesso?
    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

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