Serial comm - are 2 wires for TX only enough?


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938

    Default Serial comm - are 2 wires for TX only enough?

    Hello,

    I use the BASIC-STAMP prof dev board equipped with a RS232DCE chip and have my PIC connected with 2 wires (GND and RA1 with RS232's "TX" pin).

    Then I send some text data by pressing a button (I use the INT on RB0). The Led lets me know when the transmission starts and stops so I can double-check on the terminal's screen.

    The terminal is set to 9600 Bauds, no parity, 8 bits and 1 stop bit.

    I can see bytes received (the counter increments) in the terminal screen but I cannot see any caracter apearing on the screen.

    Since I'm new to PICs, I don't use the USART features of the 16F88 at that time.

    What am I doing wrong?

    This is the code.

    MAIN:

    IF INTCON.1 = 1 then 'If INT happens, then...
    INTCON.1 = 0 'Clear INTERRUPT
    HIGH Portb.4 'Switch on Led - start transmission
    SEROUT2 Porta.1, 84, ["TEST", 10, 13] 'Print this text in the terminal screen
    LOW Portb.4 'Switch off Led - stop transmission
    ENDIF

    GOTO MAIN

    END
    Roger

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    flotulopex, What terminal emulator program are you using? Assuming you are using a 4Mhz. oscillator and some kind of inverting RS-232 driver you should be seeing the string being sent. I would first make sure the terminal emulator program is set for the correct baud rate. If the terminal emulator program is receiving any characters, even at the wrong baudrate you will be detecting some kind of count.

    Dave Purola,
    N8NTA

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    Hi Dave,

    I use de Micro Code Studio's terminal.

    Changing the baudrate will sometimes make strange symbols apear (like @#%&/...).

    In any case, the received bytes count is 22 when sending the "TEST" message.

    I set the PIC to work with the internal RC (don't know if I have to set something else) in the CONFIG word (=IntRC).

    Isn't it necessary to have some kind of clock to synchronise the PIC with the terminal?

    Is there something wrong with my code?

    Would you know a different and maybe "better" way to check the program?
    Roger

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    flotulopex, It sounds like your baudrate is off frequency. You should have at least a 4 Mhz. osc. for reliable serial communications. Does the processor you are using have an internal 4 Mhz. osc? If not I would suggest using a 4 Mhz. resonator with the caps internal.

    Dave Purola,

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    Okay.

    I'll try and come back later.
    Roger

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Be sure you're using the right mode (inverted or not)
    Be sure your PORTA have not multiplexed analog stuff (like adc, comparator and such). If so you must disable it.

    On the F88 place those llines at the top of your code.
    ANSEL=0
    CMCON=7

    Another thing.. if you use the internal OSC, be sure you set it correctly.
    OSCCON=%01100000 ' 4MHZ

    by default, this pic run @32khz
    a+
    Last edited by mister_e; - 28th August 2006 at 16:00.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    Great,

    I added both ANSEL and CMCON settings as you suggested and it works fine now (I can see "TEST" in the terminal screen).

    I'm going back to the data sheet and try to understand what these settings change to my prog.

    I'll also try to "play" with the oscillator settings since this is not absolutely clear to me at that time.

    Thanx a lot for your help.
    Roger

  8. #8
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    938


    Did you find this post helpful? Yes | No

    Default

    After a few more tests, ANSEL and CMCON don't affect the PIC's behaviour.

    The key seems to be the oscillator OSCON setting.

    Before I got your help, I was using an external 20Mhz ceramic resonator. Nothing worked.

    I changed to the internal oscillator with default settings = 31,25kHz. Nothing worked either.

    To make it work, I set the oscillator to 4MHz as suggested by Mister_e.

    I also tried all the other possible internal oscillator (IRCF) settings; apparently, only 4MHz is working.

    I read the PBP help file under the SEROUT2 command. Nothing specifies that serial communication is working only with 4MHz.

    I'm not using the USART functionality of this PIC. Is there any info I'm missing somewhere else?
    Roger

  9. #9
    Join Date
    Aug 2005
    Posts
    95


    Did you find this post helpful? Yes | No

    Default

    Make shure your fuse settings are correct before you program the pic and if you are going to use a 20Mhz oscillator remember to add the line DEFINE OSC 20

    Hope it helps
    Sphere.

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Sure the DEFINE OSC 20 have to be inserted... but you have to modify the config fuse too... case not, it will neever ever work

    Look at http://www.picbasic.co.uk/forum/showthread.php?t=543

    you must set the OSC fuse to HS
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. 2 PIC, serial communication
    By lightgreen in forum Serial
    Replies: 6
    Last Post: - 21st November 2009, 15:20
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. 16F877, DS18S20 and Serial Comm Problem
    By YellowTang in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th April 2004, 10:36
  5. serial comm from Pic to STAMP
    By d1camero in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th April 2004, 23:58

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