Issue with 12F609


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2013
    Posts
    2

    Default Issue with 12F609

    I have been using the 12F510 for a project for a while but chose to upgrade to the 12F609 because of the greater number of internal pullups and interrupts. Since size and part count are critical in my project I was running the 12F510 on the internal oscillator. This was going fine, but when I tried to get the 12F609 working I had no luck.
    All I'm trying to do at this stage is get a simple port toggling programme running, once I've got that working my actual code can easily be ported from the 12F510 to the new PIC.
    The toggle code is below.
    Code:
    #CONFIG
        ifdef PM_USED
            device  pic12F609, intoscio, wdt_on, mclr_off, ioscfs_8mhz, protect_off
        else
            __config _INTOSCIO & _WDT_ON & _MCLRE_OFF & _IOSCFS_8MHZ & _CP_OFF
        endif
    #ENDCONFIG
    
    DEFINE OSC 8
    
    ANSEL = 00000000
    
    TRISIO = 0
    
    MAIN_LOOP:
    high GPIO
    pause 1000
    low GPIO
    pause 1000
    goto main_loop
    Obviously it just toggles the outputs each second. The code compiles fine and I uploaded it onto a PIC, then connected an LED up to GP2 (through a resistor) to monitor the state of the output.
    When I powered the PIC up the code doesn't seem to run correctly. The LED will either be on or off constantly without changing.
    I'm guessing that I've missed something in the configuration, but I don't know what. As far as I can tell the #config block is correctly set up for internal oscillator, 8MHz, digital I/O on all pins and MCLR off. Inputs are all set to digital (although that shouldn't matter when using the pins as outputs, if I'm reading the datasheet correctly) and all the pins are set as outputs.
    I'm stumped as to why it doesn't work, but there must be something I've missed. If anyone could offer any suggestions I would be very appreciative.

  2. #2
    Join Date
    Mar 2013
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Issue with 12F609

    I went back over the configs and fixed it up a bit- still no good.

    Code:
    #CONFIG
        ifdef PM_USED
            device  pic12F609, intoscio, wdt_on, mclr_off, ioscfs_4mhz, protect_off
        else
            __config _INTOSCIO & _WDT_ON & _MCLRE_OFF & _IOSCFS_4MHZ & _CP_OFF
        endif
    #ENDCONFIG
    
    DEFINE OSC 4
    
    ANSEL = 00000000
    
    TRISIO = 0
    low GPIO
    
    MAIN_LOOP:
    high GPIO
    pause 1000
    low GPIO
    pause 1000
    goto main_loop

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


    Did you find this post helpful? Yes | No

    Default Re: Issue with 12F609

    Code:
    HIGH GPIO
    obviously ... you have forgotten something ...

    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 " !!!
    *****************************************

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Issue with 12F609

    It looks from your code you are not setting the bit you want to toggle. the statement should be HIGH GPIO.2 or LOW GPIO.2. By saying just GPIO you are trying to set the entire port. Also if you are trying to use port pin 2 you are not setting it for output mode. That should be TRISIO.2 = 0 to set the port pin 2 to output. I hope this helps....
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Issue with 12F609

    You need to set the port pin tris register for output that you are trying to use as an output. Your message says that you are trying to connect an led to port pin 2 but you are setting port pin 0 as an output. Also you are trying to set the entire port high instead of the individual pin. It should be HIGH GPIO.2
    Dave Purola,
    N8NTA
    EN82fn

  6. #6
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Issue with 12F609

    I'm ASSUMING the 12F683 and 12F609 are the same for GPIO and TRISIO commands. I'm also ASSUMING you can't tell a whole GPIO to turn on or off like you did with "high GPIO".

    That being said your program should look like:

    cmcon0 = 7 'turns comparators off
    ansel = 0 'all ports digital
    adcon0 = 0 ' adc off
    trisio = %001000 ' all out except GPIO.3

    define osc 8
    osccon = %01110111 ' you need to check this but I'm pretty sure it's right to set up a stable 8 MHz internal oscillator

    MAIN_LOOP:
    high GPIO.2 'if LED is on GPIO.2
    pause 1000
    low GPIO.2
    pause 1000
    goto main_loop

    If you look in the PBP2.6 manual it spells some more stuff out. They either forgot it in PBP3.0 or decided to keep you guessing.

    Best Wishes

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: Issue with 12F609

    Obviously ...

    HIGH or LOW GPIO is an error ...

    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 " !!!
    *****************************************

  8. #8
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Issue with 12F609

    I've been looking for this thread for some time and haven't been able to find it again. I thought I'd only dreamt of the topic. Glad to see the admin Gods let it return.

    One issue I found with my code is that it should be DEFINE OSC 8. I recently had the epiphany, after reading the manual of course, that defines are case sensitive. trisio, gpio, cmcon0, adcon0 and ansel are not case sensitive. Keep that in mind as it will save you many brain cells.

Similar Threads

  1. I2C issue
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 18th October 2011, 22:53
  2. 12f609
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th October 2009, 18:24
  3. 9V with 4Ah issue
    By Security in forum Off Topic
    Replies: 19
    Last Post: - 25th September 2008, 14:53
  4. LCD issue - what does FLAGS = 0 really do?
    By BrianT in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th February 2008, 05:26
  5. Code Issue - select case or 'if' issue - not sure why
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th October 2007, 08:52

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