Help with pic16f690 -max232cpe


Closed Thread
Results 1 to 2 of 2
  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
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41

    Default

    I have never used HSEROUT before but I use SEROUT.

    Try this code just change your output pin from PORTB.0 to what ever one you are using:

    Code:
    DEFINE OSC 4
    
    Baud   con     2                           ' Define serial mode
    
    main:
       Serout PORTB.0,Baud,["Hello World",13,10]
       pause 1000
    goto main
    If the "Baud con 2" doesn't work change it to "Baud con 6"
    This is the Mode - 2 is 9600 TTL True and 6 is 9600 TTL Inverted
    Last edited by wolwil; - 17th April 2010 at 17:50.

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