Pic18F4455 to PC communication RS232


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

    Default Pic18F4455 to PC communication RS232

    Hi,
    Following is the code I have as I am just trying to get my PIC to communicate both ways with a PC using RS232. With this code, I can get the computer to send characters to the pic, which show up on my LCD screen. However, the character I send from the PIC to the PC, does not show up on the computer. I am using the Serial Communication Window in Microcode Studio. Compiler is PicBasic Pro. I have the RX/TX lines directly connected to the Serial cable on the computer, and I have also tried using resistor in series, with no luck. Please help with any ideas!

    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''
    DEFINE OSC 32

    DEFINE LCD_DREG PORTD 'LCD data port
    DEFINE LCD_DBIT 0 'LCD data starting bit (0 or 4)
    DEFINE LCD_RSREG PORTB 'Register select port
    DEFINE LCD_RSBIT 7 'Register select bit
    DEFINE LCD_EREG PORTB 'LCD enable port
    DEFINE LCD_EBIT 6 'LCD enable bit
    DEFINE LCD_BITS 8 'Defines the number of bits wide
    DEFINE LCD_LINES 2 'Sets the number of LCD lines
    DEFINE LCD_COMMANDUS 2000 'Sets the LCD command delay time in us
    DEFINE LCD_DATAUS 50 'Sets the LCD data delay in us

    TRISB = %00011111
    PORTB = %00000000
    TRISE.0 = 0 'Set PORTE.0 to output
    TRISE.1 = 0 'Set PORTE.1 to output
    TRISE.2 = 0
    TRISD = 0

    TRISC = %10010000 ' Bits 7 & 4 set as Inputs
    PORTC = %00000000 ' All off to start

    bootupscreen:

    LCDOUT $fe,1 'Clear LCD screen
    LCDOUT "USART TESTING" 'Put up self test display

    Vars: Tx var PORTC.6
    Rx Var PORTC.7
    rec var byte[1]

    loop:
    serin2 rx, 84, [STR rec\1]
    lcdout $fe, 1, "RECEIVE = ", STR rec\1
    serout2 tx, 84, ["@#$"]

    goto loop

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    With a "direct" serial connection to your PC use inverted mode.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    anmproj's Avatar
    anmproj Guest


    Did you find this post helpful? Yes | No

    Default Inverted signal...

    Thanks for your response! All it needed is the signal to be inverted and some tweaking on the baudrate. Works very well now.

Similar Threads

  1. RS232 into 2 PC ports
    By manxman in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th August 2008, 13:33
  2. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 20:39
  3. Communication between PC and PIC16f876
    By knsteam in forum Serial
    Replies: 11
    Last Post: - 26th June 2007, 09:59
  4. 18F458 to PC communication Help
    By shawn in forum Serial
    Replies: 4
    Last Post: - 11th February 2007, 19:24
  5. Interrupt and Serial communication to PC.
    By obaskirt in forum mel PIC BASIC
    Replies: 2
    Last Post: - 17th June 2005, 20:01

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