SERIN in acii, hex, decimal?


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The internal osc isn't normally accurate enough for reliable serial communications.

    It may work in one app, then not in the next. If you want reliable serial comms, go for an
    external crystal or resonator. But if you are using the internal osc on this PIC, then you for
    for sure want the DEFINE OSCCAL_1K 1 in there to load the factory osccal calibration value
    at power-up.

    Pretty much any decent device programmer will preserve the factory osccal value, but if it
    doesn't, it's never going to work right with DEFINE OSCCAL_1K 1 in your code.

    I.E. if your device programmer erases the last program memory location where the RETLW
    xx (XX being the factory cal value to load into OSCCAL), and you insert DEFINE OSCCAL_1K
    1 in your code, it creates a nasty loop you'll never get out of.

    PBP inserts a call to the last program memory loaction when you include this DEFINE. If the
    RETLW xx isn't there, it rolls-over back to location 0, and you land on the call repeatedly.

    You can check by just reading your 12F with your programmer and checking to see if the
    last program memory location has been erased.

    If it has been erased, there are several threads here on how to fix this.

    I have an external crystal here that has 5.000 on it, so I assume that is 5mhz. Will this work
    Nope. PBP doesn't support 5MHz osc speeds. Check in the back of your PBP manual in the DEFINE
    section for a list of supported osc speeds.

    There's also a schematic in your manual for connecting an external crystal with caps.

    If you're using a 3-pin resonator with internal caps, ground the center leg & connect the
    other two to the PIC OSC1 & OSC2 pins.
    Last edited by Bruce; - 3rd March 2009 at 00:35.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    Join Date
    Feb 2009
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Ok, I checked the 03ff location on the 6 different chips that im messing with and two of them have 3fff in that location and as my luck would have it as I switched chips in and out, these are the ones that I tried the 'DEFINE OSCCAL_1K 1' to no avail. The other 4 had values in the 34xx range so i guess that these are fine. I gave all 4 of those this code with the added 'DEFINE OSCCAL_1K 1' and all 4 display what they should in hyperterm. My luck seems to be this way sometimes. Little by little i learn.

    Thanks again guys. Im off to see if this fixes my serin problem.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Ones with 34xx should be OK. The 34h = the RETLW instruction. XX is the value returned
    in W.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Feb 2009
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Ok, everthing is working great at 2400 baud. The display and everything is working. Now I need to bump it up to 9600 baud. I read that this requires a faster crystal. Does a standard 2 wire crystal work or are there special ones to use? Is 8mhz all I need? How does one 'hookup' and external crystal. On a propellor chip, its a piece of cake because it has dedicated pins for it, not so on the 12f675. After its attached do I just add a DEFINE OSC 8 to replace the DEFINE OSC 4 command and set the serin to N9600 to replace N2400?

    Thanks all.

    Jason

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sccoupe View Post
    Ok, everthing is working great at 2400 baud. The display and everything is working. Now I need to bump it up to 9600 baud. I read that this requires a faster crystal. Does a standard 2 wire crystal work or are there special ones to use? Is 8mhz all I need? How does one 'hookup' and external crystal. On a propellor chip, its a piece of cake because it has dedicated pins for it, not so on the 12f675. After its attached do I just add a DEFINE OSC 8 to replace the DEFINE OSC 4 command and set the serin to N9600 to replace N2400?

    Thanks all.

    Jason
    Hi Jason,
    1. 2 wire crystal works, you do need to use capacitors from the crystal pins to ground.
    2. DEFINE OSC xx where xx is the value of the crystal used
    3. Yes simply change the number from 2400 to 9600 assuming you have included modedefs.bas
    4. Here is the gotcha . . .You must change your config statement from _XT_OSC to _HS_OSC, this allows the PIC to consume enough power to oscillate at the higher FREQ.
    I ALWAYS put a config statement into my code at the beginning. The other way is to edit the 12F675.inc file it the root directory of PBP to reflect this change. That is where the DEFAULT config statement resides for THIS chip. You will need to open that file in either case, because even if you choose to write the config statement into your code you will need to comment out ( ;__config . . . ) the existing config statement. Be advised there 2 different config statements in there 1 for MPASM and 1 for the PM assembler,
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Have you read post #4 yet...;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Feb 2009
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Have you read post #4 yet...;o}
    Hmmmm, will that also work for serin without a max chip?


    What kinda of capacitors do I need for the external crystal? What pins to hook them up to and what code tells the chip what pins the external crystal is on?

    Thanks again all!

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    All right Jason,
    Grab that data sheet, it's right there under the table leg, open it up to section 9.2.2, you will find a nice little chart, and schematic. That chart will tell you the caps need to be in the range of 15 to 30 pf, and will recommend higher capacities make the oscillator more stable but delay it's start up. . . Please download it (the data sheet) and look this over. That said, most use 22 - 27pf, or resonators as they are easier to mess with. Reading the data sheets are a must, you will understand them more every time you do, and they are free.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Serin Help - ASCII to Decimal
    By Dino308gt4 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th October 2009, 23:00
  2. Hex to Ascii to Decimal
    By khoog in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st July 2009, 05:27
  3. hex ascii help please
    By ffr58kk90 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 29th December 2006, 21:09
  4. Convert Hex to Decimal???
    By RONKON in forum mel PIC BASIC
    Replies: 2
    Last Post: - 9th May 2006, 02:14
  5. Reading a Hex value from a Modem and showing it as Decimal..
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th March 2005, 17: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