MAX232 and DB9 connecter


Closed Thread
Results 1 to 11 of 11
  1. #1
    Tomas's Avatar
    Tomas Guest

    Default MAX232 and DB9 connecter

    Hi there,

    I have connected pin 5 of the the DB9 to GND.
    My crydtal speed is 4MHz.

    But don't know which DEFINEs to include in the code and no idea what "TRUE" mode is and how to do it, sorry.
    Where do i set this mode? I have told that 9600 will not work for a 4MHz crystal and so changed the mode to 4800, see the code below.
    Have tested the Hyterterm, COM-Port, Serial Cable it is as explained no problem.
    The problem might be with MAX232, one of the pins gives only 0V and the other one gives between the range of -1.5V up to -8.6V.

    Pin 12 (R1 OUT) of the MAX232 which is connected to pin 26 (RX) of '877 gives 0V

    Pin 11 (T1 IN) of MAX232 which is connected to pin 25 (TX) of '877 gives 2.80V and 4V

    Pin 13 (R1 IN) of the MAX232 which is connected to pin 3 of DB9 gives almost 0V

    Pin 14 (T1 OUT) of the MAX232 which is connected to pin 2 of DB9 gives between -1.5V up to -8.6V


    What do you think where should i look for mistakes?

    I just want to get the code below work to see my first "Hellow World"

    ' PicBasic Pro program to send "Hello World" on serial port

    ' Define LOADER_USED to allow use of the boot loader.
    ' This will not affect normal program operation.
    'Define LOADER_USED 1

    'Include "modedefs.bas" ' Mode definitions for Serout
    TRISC = %00000010

    loop: Serout2 PORTC.6,4800,["Hello",10,13] ' Display "Hello", next line
    Pause 500 ' Wait .5 second

    Serout2 PORTC.6,4800,["World",10,13,10,13] ' Display "World", skip a line
    Pause 500 ' Wait .5 second

    Goto loop ' Do it forever
    End


    Best Regards,
    Tom.

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Your MAX232 is probably defective.

    Try the following with PortC.6 of the PIC directly connected to Pin 2 of the PCs DB9 (and GND connected to Pin 5 of DB9)


    ' 4800 Baud 8N1

    DEFINE OSC 4

    loop:
    Serout2 PORTC.6,$40BC,["Hello",10,13]
    Pause 500
    Serout2 PORTC.6,$40BC,["World",10,13,10,13]
    Pause 500
    Goto loop
    End

    The Mode is marked RED


    You might also want to try a different Pin (i.e. RB4) and try to add a 4k7 pullup.


    There is one thing I have found a while ago:

    If you have tried the HSEROUT statement your PIC might behave strange when using SEROUT or SEROUT2.

    If there is a HSEROUT statement somewhere in the Code (even at a position normal program execution never gets to) causes that the PICs internal USART remains connected to the Port Pin.

    To solve this erase your PIC and start coding at a new (blank) project.

  3. #3
    Tomas's Avatar
    Tomas Guest


    Did you find this post helpful? Yes | No

    Post MAX232 and DB9 connecter

    Hi, there thanks for the reply.
    I have tried it as explained, connecting PORTC.6 direct to DB9 pin 2. And still could not the the message.
    I'm not sure if it is the MAX232 chip which is cousing the problem, MAX232 behavs as follows:

    Wheb TX (RC6) from '877 is connected to pin 11(T1 IN), pin 14(T1 OUT) gives -10.2V, this pin is connected to pin2 of the DB9 connecter. (Am i sending a negative voltage level).

    But pin 7(T2 OUT) gives 9.6V and this pin is left float.
    This connection is supposed to work, it doesn't look like it at the moment.

    Where can i find a working code just for testing purpose? A code which sends and receives data.

    Cheers,
    Tom.

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Tom,

    this is a working piece of code for direct connection (no MAX232)

    loop:
    Serout2 PORTC.6,$40BC,["Hello",10,13]
    Pause 500
    Serout2 PORTC.6,$40BC,["World",10,13,10,13]
    Pause 500
    Goto loop
    End

    this is a working piece of code for use with MAX232

    loop:
    Serout2 PORTC.6,$BC,["Hello",10,13]
    Pause 500
    Serout2 PORTC.6,$BC,["World",10,13,10,13]
    Pause 500
    Goto loop
    End

    both the versions have been tested on a 16F876

    Are your settings in hyperterm correct?


    There is one more thing:

    If you are using your Loader cable for connection with Hyperterm it wont work.
    Hyperterm sets Pin4 at the COM Port to +12V which causes a LOW-Level at the MCUs MCLR Pin.
    Your MCU will not start as long as Hyperterm is connected

  5. #5
    Tomas's Avatar
    Tomas Guest


    Did you find this post helpful? Yes | No

    Default MAX232 and DB9 connecter

    Hi again,
    What cabel can i use? The cable i have is connected to my project board and COM1
    Cheers,
    Tom

  6. #6
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    For a quick test just take two wires,

    one from PortC.6 to Pin 2 on the DB9
    one from GND to Pin5 of the DB9

    I'm sorry Tom,
    but we are discussing all the same things over and over.

  7. #7
    Tomas's Avatar
    Tomas Guest


    Did you find this post helpful? Yes | No

    Default MAX232 and DB9 connecter

    Hi,
    Well i was not talking about the connection between the '877 and DB9.
    I was told that the cable i'm using (to connect my project board and the computer) at the moment might not work so how do i connect the DB9 from my board with the serial port (COM 1) in my computer?
    Can i just use to wires, pin 2 and 3 from DB9 on my project board to connect to the pins 2 and 3 of the computers serial port. This seems a bit unusall to me.

    Cheers,
    Tom

  8. #8
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    It is impossible to answer your questions without having had a look at the schematic of your "project-board"

  9. #9
    Join Date
    Mar 2004
    Location
    Manila
    Posts
    18


    Did you find this post helpful? Yes | No

    Default

    hi,

    pin 2 of PC serial com (DB9) is RX.... so you have to connect here the TX of your board

    pin3 of PC serial com(DB9) is TX... so you have to connect here the RX of your board

    pin 5 of PC serial com(DB9) is GND... so yuo have to connect here the GND of your board.

    hope this help
    brenda

  10. #10
    Join Date
    Sep 2003
    Location
    INDIA
    Posts
    161


    Did you find this post helpful? Yes | No

    Default Solid State MEMS Inclinometer Model SQ-SI2X-360DA

    Just wanted to raise another querry on this old thread , without starting a new one.

    I am interested in interfacing the above mentioned Inclinometer to the PIC and displaying the relevant information on the LCD.

    My target MCU is 16F877A @ 20Mhz.

    One of the problems I am facing is how to interface the PIC at 115,200 or 56,700 baud to read the information from this sensor.

    Any help would be appreciated.

    regards

  11. #11
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Question What is your crystal frequency ?

    Hi Charu,

    Please post your crystal frequency. The baud rate generator works for certain rates at certain crystal frequecy. Otherwise you have to do away with the hardware USART and have a asm based routine. It is also possible with PBP. But then you are left with little processing or housekeeping
    Regards

    Sougata

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