Simple Blink program doesnt work.


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2009
    Posts
    29

    Default Simple Blink program doesnt work.

    I just got the whole programming kit today making the jump from the basic stamp and picaxe chips, so im not a total noob. I have a few 12f675's and a 12f629 and cannot get the simple Blink sample program to work. If I even program a HIGH 0 command, I only get 2.5 volts from pin 0 with a multimeter. Im using a 7805 (5 volts) to power it. If I HIGH 1 then I get 2.5v on pin 1, so the commands are hitting the right pin, they just arent 5 volts. Also, the blink program makes the selected pin stay at 2.5v and doesnt blink. I hope this is a simple common problem?

    Thanks all.

    Jason

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Why not post your code, config settings and tell us if you are trying internal or external OSC?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Feb 2009
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    The complete code....

    Code:
    loop:   
       High 0         
       Pause 500       
    
       Low 0         
       Pause 500       
    
       Goto loop      
       End
    The circuit is +5vdc on pin 1 and ground to pin 8. Measuring voltage with a voltmeter from pin 8 to pin 7. I have tried several 12f675's and one 12f629. Not sure where to get the config, whatever was the default for the picbasic pro install.

    Thanks

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Lets start with the configs.
    In the PBP directory there is a *.inc file for every chip, this is where the chip is configured. It can also be done in code space.
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    For now look at the *.inc file
    Code:
    ;****************************************************************
    
    ;*  12F675.INC                                                  *
    ;*                                                              *
    
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    
    ;*  Notice    : Copyright (c) 2005 microEngineering Labs, Inc.  *
    
    ;*              All Rights Reserved                             *
    
    ;*  Date      : 08/31/05                                        *
    
    ;*  Version   : 2.46a                                           *
    
    ;*  Notes     :                                                 *
    
    ;****************************************************************
    
            NOLIST
    
        ifdef PM_USED
    
            LIST
    
            include 'M12F675.INC'	; PM header
    
            device  pic12F675, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
    
            XALL
    
            NOLIST
    
        else
    
            LIST
    
            LIST p = 12F675, r = dec, w = -302
    
            INCLUDE "P12F675.INC"	; MPASM  Header
    
            __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    
            NOLIST
    
        endif
    
            LIST
    The above shows internal OSC, watch dog timer is on, MCLRE is on and code protect is off.
    For now change MCLRE_ON to MCLRE_OFF. do the lower case one if you are using PM for the assembler and the upper case one if you are using MPASM for the assembler.

    The chip you are using has built in ADCs, something new from the Basic Stamp. If the pin is to be used as a digital then the ADC needs to be turned off.
    This thread is labeled PORTA... but the same applies for GPIO.
    http://www.picbasic.co.uk/forum/showthread.php?t=561

    In my opinion is will be a bad habit to stick with the Basic Stamp idea of a pin being 0 or 1 or 2. Better to get in the habit of calling the pins by the name or assigning on to it.
    Code:
    LED VAR GPIO.1
    PBP defaults to 4MHz but it is good practice to define the speed in code space.
    So make the change to the *.inc file and give this a try.
    Code:
    '16F675
    DEFINE OSC 4
    ANSEL=%00000000
    CMCON=7
    LOOP:
    HIGH GPIO.0
    PAUSE  250
    LOW GPIO.0
    PAUSE 250
    GOTO LOOP
    END
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Feb 2009
    Posts
    29


    Did you find this post helpful? Yes | No

    Default

    Ok, thats worked. Disecting it found that it was the MCLRE that made the difference. I'll read up on that as it is the only part of your explanation that I didnt understand. It seems that there are a lot of things that I need to learn in this area that were not needed with other chips. The frustration in the past with these pics may have been what pushed me to Basic Stamps, but their cost eventually pushed me to the Picaxe's. However, their inability to accomplish certain things and much lower availability to US customers has brought me back to this. I guess I need to fight my way though it this time.


    Thanks for your help mackrackit.

  6. #6
    Join Date
    Jan 2007
    Location
    Portland Oregon
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Don't give up

    I had similar frustrations when I ported from the Basic Stamps to the PICs. I found the most important thing was getting the PIC setup correctly for your application A/D, digital I/O and config bits. I printed up the data sheet for the 12F675 and left it in my library (bathroom) and read it through and through. This realy helped as I moved to other PICs as I knew what to look for (A/D, PWM, digital I/O etc) Its intresting that the masters sometimes dont show the config and setup info when they post there help code. Get a "Hello World" (blinking LED) working on a new PIC before you proceed any further on a new project. Best of luck, and keep on nearding (what my wife calls my obsession)

    Aaron

  7. #7
    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, thats worked. Disecting it found that it was the MCLRE that made the difference. I'll read up on that as it is the only part of your explanation that I didnt understand.
    Look at the chips Data Sheet for which pin is used with MCLRE. That pin must have a pullup resistor if MCLRE is enabled in the config statement.
    <br> Rather than changing the config statement in the .inc file each time I would insert a semicolon just before the first letter in the statement and insert the statement at the beginning of my code, every time.
    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. Help with DS18B20 program
    By presario1425 in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 22nd August 2012, 00:50
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. Can't get blink circuit to work :(
    By Techbuilder in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 31st January 2008, 13:00
  4. Can anyone help at getting OWIn & OWOut to work @ 16MHz?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th January 2006, 11:08
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 12:03

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