12F675 cant serout to PC


Closed Thread
Results 1 to 10 of 10
  1. #1

    Default 12F675 cant serout to PC

    Hi all,

    I have here a 12F675 and i was using it read a LM35 and send out temp to PC via serial port ( not using MAX232 ).

    The problem is that i'm facing comunication problems.
    I cant get the pic to send a correct word out !

    All i get is rubbish.

    I've seen someone here with the same problem but it was resolved with XT->HS change !

    I've tryed so many things ( speed, xtals, etc ) and nothing works

    Here's the code:

    @ DEVICE PIC12F675, MCLR_ON
    ' Master Clear Options (Internal)

    @ DEVICE PIC12F675, PROTECT_OFF
    ' Program Code Protection

    define osc 4

    Include "modedefs.bas" ' Include serial modes

    define osc 4

    ANSEL = %00000000 ' Set analog ports to digital mode

    CMCON = %00000111 ' Turn off comparator

    'TRISIO = 00001000 ' designate gpio.0,1,2,4,5 as output 3 as input

    WPU = %00000000 ' Disable pull-ups
    TRISIO = %00000 ' Set all I/O's to outputs

    out:

    low gpio.2

    Serout2 GPIO.1,396,["396",10,13] ' check if this works
    pause 200
    Serout2 GPIO.1,84,["84",10,13] ' or this
    pause 200
    Serout2 GPIO.1,188,["188",10,13] ' or this
    pause 200
    Serout2 GPIO.1,16572,["16572",10,13] ' or this
    pause 200
    Serout2 GPIO.1,N2400,["N2400",10,13] ' or this
    pause 200

    high gpio.2

    pause 500

    Goto out

    thanks for the help
    .

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


    Did you find this post helpful? Yes | No

    Default

    add that line at the top of your code
    Code:
    DEFINE OSCCAL_1K 1
    this should help
    Steve

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

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks for the tip Mister-e

    but isnt this for when using only the internal osc ?

    i'm using an external 4Mhz xtal

    .

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


    Did you find this post helpful? Yes | No

    Default

    Yup and i missed it...

    What capacitor value did you put on your Crystal? 15-22pf?

    what happen if you remove the MAX232, and use inverted mode for your baudrate???

    With the MCLR_ON, it mean you use MCLR, so i hope this pin is tied to Vcc?

    Clean psu, decoupling caps here and there?

    Did you also tried with the internal OSC?

    I don't see anything wrong in the code...
    Steve

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

  5. #5


    Did you find this post helpful? Yes | No

    Default

    I have tryed that but if i use that line it does not work ( doesnt send data nor the led in gpio.2 blinks )

    .

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


    Did you find this post helpful? Yes | No

    Default

    what happen if you change MCLR_ON to MCLR_OFF?

    Are you sure it's a 4MHZ crystal?

    Can you measure it with a scope?
    Steve

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

  7. #7


    Did you find this post helpful? Yes | No

    Default

    I'm not using any Max232

    About the MCLR, when on i hooked it to vdd, also tryed off and result is the same.

    The caps for the xtal are both 22pF

    I'm using the Serin program to get the data from serial

    .

  8. #8


    Did you find this post helpful? Yes | No

    Default

    i can try using the internal osc...but will have to use MCLR on or i will lock my pic :S

    IC-Prog has 2 choices...

    INTOSC GP4

    and

    INTOSC CLKOUT

    which one may i use ?

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


    Did you find this post helpful? Yes | No

    Default

    I'm not using any Max232
    AH CRAP, i really need new glasses... so just change your SEROUT2 baud constant to use inverted mode... and it will work

    Code:
    baud	Serout2
    ----	-------
    9600 	16488
    4800 	16572
    2400 	16780
    with 1-10K resistor in serie, this have to work.

    I would suggest you to use DEBUG, it use less code space and may work on higher baudrate with slower crystal speed.
    Last edited by mister_e; - 2nd December 2007 at 23:51.
    Steve

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

  10. #10


    Did you find this post helpful? Yes | No

    Default

    The SEROUT2 baud constant table did not worked as well...

    but...

    using DEBUG worked 5*****

    I guess it's because the low speed xtal

    Thanks once again Mister-e


    .

Similar Threads

  1. A Serial GLCD 128x64 Simple Project
    By Oldspring in forum Off Topic
    Replies: 0
    Last Post: - 8th March 2010, 20:58
  2. Serout to serial servo
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 12th August 2009, 16:46
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Keypad unlock (as in garage door possibly)
    By Fred in forum Code Examples
    Replies: 5
    Last Post: - 2nd April 2006, 04:26
  5. Replies: 4
    Last Post: - 7th September 2005, 14:11

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