PIC18F2450 Rs-232


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Hi,
    You shouldn't have to use the USART but I see no apparent reason not to when it is on the same pins as you're trying to use with SEROUT.

    If you're using SEROUT you can use any pin you like as long as it can be made an output but you must make sure that all other peripherals multiplexed to that particular pin is turned off. Start by doing a blink-a-led on the particular pin you want to use, when you have that working you should be able to get data out with the SEROUT or SEROUT2 commands.

    By the way, setting RCSTA, TXSTA etc does not effect SEROUT/SERIN commands, only HSEROUT etc. With HSEROUT you have to use a levelconverter as it can't send the data inverted - as far as I know.

    If you're going to use the USART you can only use the pins to which the USART is connected (PortC.5 and 6 in this case but some chips can switch them around to alternative pins). But again you need to make sure that any other peripheral that may be on the same pin isn't "taking over" so to speak.

    /Henrik.

  2. #2
    Join Date
    Mar 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Ok, here is what I have


    DEFINE OSC 20
    TRISC = %10111111 ' Set TX (PortC.6) to out, rest in
    TRISB = %00010000 ' Set TX (PortB.5) to in, rest outputs
    TRISA = %01111111
    SPBRG = 25 ' Set baud rate to 2400
    RCSTA = %10010000 ' Enable serial port and continuous receive
    TXSTA = %00100000 ' Enable transmit and asynchronous mode
    INTCON2.7 = 0

    pinin VAR PORTB.4 ' Define pinin as PORTB.4
    pinout VAR PORTB.5 ' Define pinout as PORTB.5

    how do I setup the SEROUT command to send "This Is a Test" ?
    how fo I setup the SERIN command to receive "Test Received" ?

Members who have read this thread : 0

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