Help with pic16f690 -max232cpe


Closed Thread
Results 1 to 37 of 37

Hybrid View

  1. #1
    Join Date
    Apr 2010
    Posts
    21

    Question Help with pic16f690 -max232cpe

    So i started to try out some serial com and after alot of struggling i have gotten it almoste to work.

    i have pickit2 with pic16f690 and a demoboard with max232.

    max232:

    pin 1 & 3 - 1uf
    pin 4 & 5 - 1uf

    pin 2 - 1uf to vdd
    pin 15 - 1uf to gnd
    and gnd to vdd 1uf

    so i have been able to recive text on my computer from the pic but it's somehow malformed.

    i try to send "Hello World", 13, 10
    and i get
    Hello0World<(8A)>

    when i stop the pic i recive the space and cr and lf

    when i make the pic hserout the hserin i returns random alphas or signs.

    my current code is as follows:

    Code:

    DEFINE OSC 4

    'intcon=0 ' Interrupts disabled
    cm1con0=0 ' Comparator 1 disabled
    cm2con0=0 ' Comparator 2 disabled
    'cm2con1=0 ' Comparator 2 disabled

    ANSEL=0 ' Pins to be Digital
    ANSELH=0 ' Pins to be Digital

    Include "modedefs.bas"

    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h 'sets bergh = 1 or 20h sets = 0
    DEFINE HSER_BAUDCON 0h ' 0h
    DEFINE HSER_BAUD 9600 '16468
    DEFINE HSER_SPBRG 25
    'DEFINE HSER_CLROERR 1


    main:
    hserout ["Hello World", 13, 10]
    pause 1000
    goto main

    and i cant figure out why!

    im using picbasic with MC studio and MPASM

    Please HELP

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 25  ' 9600 Baud @ 4MHz, 0,16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    Tray to replace your USART setting with the one given above.

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Apr 2010
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Code:
    DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
    DEFINE HSER_SPBRG 25  ' 9600 Baud @ 4MHz, 0,16%
    DEFINE HSER_CLROERR 1 ' Clear overflow automatically

    Tray to replace your USART setting with the one given above.

    Al.
    Thx for replying, but i have tried that to. and still no go. when i change the usart settings to use 2400 bauds it wont work at all, then i just get alphas and numbers.

    can there be something wrong with my connections. iv tried with 2 max232 and same result. have i connected something wrong would this result in such an error.

    and one thing more, when i send a alpha, let's say "t" if i repeat that like 10 timer with 50ms pause i revice the correct letter back maybe once <- if i look a hserin and hserout

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    What kind of terminal are you using?

    Can you post your wiring ?

    Al.
    All progress began with an idea

  5. #5
    Join Date
    Apr 2010
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    What kind of terminal are you using?

    Can you post your wiring ?

    Al.
    Well it looks like i found the probleme, i looked over the max232 data sheet and i frogot to connect vcc and gnd

    Now i recive the expected output but it wont read the input.

    Code:
    DEFINE OSC 4
    
    'intcon=0 ' Interrupts disabled
    cm1con0=0 ' Comparator 1 disabled
    cm2con0=0 ' Comparator 2 disabled
    'cm2con1=0 ' Comparator 2 disabled
    
    ANSEL=0 ' Pins to be Digital
    ANSELH=0 ' Pins to be Digital
    
    Include "modedefs.bas"
    
    DEFINE HSER_RCSTA	90h
    DEFINE HSER_TXSTA	24h 'sets bergh = 1 or 20h sets = 0
    'define HSER_BAUDCON 0h ' 0h
    'DEFINE HSER_BAUD	9600 '16468
    DEFINE HSER_SPBRG	25
    DEFINE HSER_CLROERR 1
    
    rxVal Var Byte
    HSEROUT ["Waitin signal"]
    main:
        hserin [rxVal]
        hserout [rxVal]
        'HSEROUT ["Test should work"]
        pause 20
    goto main
    Any ideas?

    And Thx for the help so far, sorry for not checking the schematics better
    and im using 232analyzer terminal software
    Last edited by krise86; - 18th April 2010 at 21:16.

  6. #6
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Can you post the schematic?

    Al.
    All progress began with an idea

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts