PIC18F2450 Rs-232


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Posts
    43

    Default PIC18F2450 Rs-232

    I have a Olimex PIC-28 board. I have a PIC18F2450 and a ST232 installed.

    I have pin 17 on the PIC18F connected to pin 12 on the ST232
    I have pin 18 on the PIC18F connected to pin 10 on the ST232

    I am using this command in PBP:
    SEROUT PORTC.6,T9600,["This is a test"]

    I have a scope attached and the PIC pins 17 and 18 are always high, they never change.

    Is my wiring wrong? or do I have to set some configuration bits to make this work?

    Thanks,
    Bob

  2. #2
    Join Date
    Mar 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    BTW,
    the SEROUT PORTC.6,T9600,["This is a test"] command is in a loop that updates every 2 seconds.

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

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

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

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

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    What configs are you using? If it is the default ones in pbp/18f2450.inc then they are set to:

    Code:
            __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
            __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H,_PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
            __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _BBSIZ_BB1K_4L & _XINST_OFF_4L
    That should get you 48 mhz instead of 20 mhz.

    And for the hardware, do you have the 3.3 volt jumper on, or off?

    Can you get the chip to blink an LED or something to make sure its running?

    If you decide to go with hardware uart here are some defines for 48 mhz.

    'DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    'DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    'DEFINE HSER_SPBRG 77 ' 9600 Baud @ 48MHz, 0.16%
    'DEFINE HSER_CLROERR 1 ' Clear overflow automatically

  8. #8
    Join Date
    Mar 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    I have an external 20mhz oscillator. Can you tell me what I need to do to use SEOUT2 and SERIN2 on pins PORTB.5 and PORTB.4?

  9. #9
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by PlantBob View Post
    I have an external 20mhz oscillator. Can you tell me what I need to do to use SEOUT2 and SERIN2 on pins PORTB.5 and PORTB.4?
    Hi Bob,

    Are you able to blink an led with the chip? It may sound stupid, but that eliminates a lot of other issues.

    With the 20 mhz external OSC and the default configs, your chip will run at 48 mhz. So if you are using the default configs, you will have to define your OSC. You might also try Darrel's All Digital. It takes care of some of the analog settings that can throw us for a loop. It is located here: http://www.picbasic.co.uk/forum/cont...54-All-Digital
    Im away from my PBP right now, but you should be able to use the PBP serout example from the manual.

    Let us know if you get stuck.

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


    Did you find this post helpful? Yes | No

    Default

    You definitely do not want to enable the hardware USART if you want to use any bit-banged serial routines like SEROUT/SERIN or SEROUT2/SERIN2 on the hardware RX/TX pins.

    Enabling the hardware USART prevents you from using the TX/RX pins as digital, so bit-banged serial commands can't control these pins.

    And double-check your connections to the ST232. I suspect you have TX and RX backwards.
    Last edited by Bruce; - 3rd February 2011 at 20:57. Reason: ST232 Connections
    Regards,

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

  11. #11
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    And double-check your connections to the ST232. I suspect you have TX and RX backwards.
    he is using this board http://www.olimex.com/dev/pic-p28.html so wiring should be correct. (for the hardware serial port that is)

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