LCD readout with 12f629


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Posts
    35

    Question LCD readout with 12f629

    I have a dedicated 16f84 pic tied to a LCD display which allows me to use Debug commands to readout parameters with a single wire at 2400 baud from PIC's under development.
    I am now working with a 12f629 PIC and can not get readable data from it. The program does function. I am using the 629's internal RC oscillator at 4mhz and my Debug settings reflect this. I changed the REG setting to GPIO.5 but the compiler says its not a defined pin.


    Define OSC 4 ' Set Xtal Frequency
    Define DEBUG_REG PORTB.3 ' Debug PortB for 16f84
    Define DEBUG_BIT 2 ' *** Debug pin Bit-0 ***
    Define DEBUG_BAUD 2400 ' *** Debug Baud Rate ***
    Define DEBUG_MODE 1 ' Set Serial Mode to Inverted
    Define DEBUG_PACING 200 ' Delay 'in Us' between

    I also tried the serial communicator with the SEROUT command but couldn't get anything readable.

    N2400 con 4

    Serout GPIO.5,N2400 ,[seq,10]

    I have read: Debug commands do not work on 12 bit core PICs (?)
    An external xtal is necessary (tried that}
    The defines may have to be tweaked (?)

    Does anybody have any other suggestions?
    Thanks,
    Homerclese

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Homerclese View Post
    Define DEBUG_REG PORTB.3 ' Debug PortB for 16f84
    Does anybody have any other suggestions?
    Suggest you change the DEBUG_REG port...

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Read the 12F629 with your programmer.
    Check the Last location in program memory.
    If you're lucky (very lucky), there will still be a value there for calibrating the internal oscillator.

    If there is? You can use ...
    Code:
    DEFINE OSCCAL_1K 1
    If Not? You can set the Internal Oscillator to center frequency with...
    Code:
    OSCCAL = $80
    --------------------

    The 12F629 is a 14bit core, so debug will work. It's also the smallest in code size. Which is a good thing for a 12F629 with only 1K of Flash.

    --------------------

    And, like skimask almost said. Get rid of the .3 in your Define DEBUG_REG
    Define DEBUG_BIT selects the PIN to use.
    DT

  4. #4
    Join Date
    Oct 2005
    Posts
    35


    Did you find this post helpful? Yes | No

    Thumbs up

    Another "forest for the trees" thing again!

    REG GPIO - BIT 5 Got it! Thanks.

    The value in the last memory location shows up in the calibration section of the memory read. The value was still there (3438). The OSCAL define fell out of the program as I played with the code. Debug works now.

    Stepping back a bit, when I first started playing with the 12f629 I thought I had damaged two chips. They would work and then stop. Resetting would sometimes get them going. At one point they both seemed dead. Now, I read them out and find no calibration value. I have the "calibration program" option unchecked, so I don't know how they got wiped out. I tried OSCAL $80 and the chip came to life. It looks to be running about 40% faster than it should. Because of this, Debug stopped working with this chip.

    So.....

    It seems that the calibration value is more than just a tweak. Loose it and you stop. Yes?
    The rest of my 12f629's have the same value (3438) in the last location. Can I write to that location and restore the chip, or can I find an OSCAL value that comes close? Is that what OSCAL $80 does?
    Thanks,
    Homerclese

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Homerclese View Post
    It seems that the calibration value is more than just a tweak. Loose it and you stop. Yes?
    The rest of my 12f629's have the same value (3438) in the last location. Can I write to that location and restore the chip, or can I find an OSCAL value that comes close? Is that what OSCAL $80 does?
    Lose the cal value and your 2400 baud value becomes something like 2300 or 2500 or whatever. Baud rates can only stand to be about 5% off at the very most. The datasheets say that the OSCCAL value can change the internal clock speed from -12% to +12%, so the 40% might not be entirely correct.

    As far as putting $80 back into OSCCAL, I think it was more coincedence that everything work. Most likely that a value of $80 in OSCCAL brings you that much closer to 4mhz and you might still have to do some tweaking to it. As far as I know, the best way to get the correct value is to write a program to switch a pin and watch it on an o-scope or freq counter. I'm not sure if there are any programmers out there that'll find the correct value for you. I could be wrong though. My Warp13a won't do it for me.

  6. #6
    Join Date
    Oct 2005
    Posts
    35


    Did you find this post helpful? Yes | No

    Thumbs up

    I wrote a little pin out program and read it with a frequency counter. With a good calibration value for a 4MHZ clock, the pin frequency was 97.48 KHZ.

    With a 12F629 PIC that lost it's calibration value, using OSCAL $80 the frequency was 115.35 KHZ.

    Changing the OSCAL values yielded:

    $70 = 112.25 KHZ
    $50 = 105.04 KHZ
    $30 = 98.40 KHZ
    $2D = 97.40 KHZ

    So OSCAL = 2D to get this particular chip back on frequency. Debug is working again.
    Thanks,
    Homerclese

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Homerclese View Post
    I have the "calibration program" option unchecked, so I don't know how they got wiped out.
    It's not only the programmer that can cause the loss of the calibration.

    Another way to lose it is to turn on Code Protection.
    When protection gets turned off to program the chip the next time, the chip itself erases everything to protect from someone just turning of protection and reading the program.
    The oscillator Cal gets erased along with the program.

    So Code protection probably shouldn't be turned on until the Last time it's programmed.
    DT

  8. #8
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Wink painted ROM ...

    Hi, Homer

    I saw I-don't-remember-where a simple trick not to loose the cal value ...

    The chip has 8 pins ... the cal value 8 bits ...

    just put a drop of white paint facing the pins corresponding to "1" bits ... or a small sticker under the chip.

    simple !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

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