PIC18F2450 Rs-232


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    More Information:

    TRISC = %10111111 ' Set TX (PortC.6) to out, rest in
    TRISB = %00000000 ' Set PortB to 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

  2. #2
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default

    If you want to control ports.Frist of all change them to "0",with this command PORTB=$00

  3. #3
    Join Date
    Mar 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    TRISB = %00000000 is the same thing and that is already in my code.
    I don't think Portb has anything to do with my USART operations.

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


    Did you find this post helpful? Yes | No

    Default

    TRISB = XXX
    PORTB = XXX
    are not the same thing. One sets direction and the other is on/off.

    What happens if you pull the 232 chip?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Mar 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    Doing further research, it looks like I have to use HSEROUT withe the USART pins on the PIC18F2450. I have tested with HSEROUT and I still don't get any serial out.

    Can I use other Pins and use SEROUT? if so what do I need to specify in my code? I have a 20mhz clock and need 9600,n,8,1

    I disconnected the 232 chip and the result is the same.

  6. #6
    Join Date
    Jan 2011
    Location
    Skopje,Macedonia
    Posts
    71


    Did you find this post helpful? Yes | No

    Default

    Why do you put 9600bauds put 2400
    please post the code!!

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


    Did you find this post helpful? Yes | No

    Default

    I see what you did now.
    Remove the hardware serial stuff.
    SPBRG = 25 ' Set baud rate to 2400 RCSTA = %10010000 ' Enable serial port and continuous receive TXSTA = %00100000

    Then you can use SEROUT on those pins. You may want to look at SEROUT2, has more options.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    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.

  9. #9
    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