12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    If you copied the HEX and pasted it into notepad... probably why you had problems.

    Now, the PICkit1 board has the LEDs in a matrix. So the coding is a little different than just HIGH this and LOW that.

    Lesson #1
    The PIC has three states a pin can be in.
    OUTPUT HIGH
    OUTPUT LOW
    INPUT

    Here is the code to light the first three LEDs on the PICkit1 on and off, in sequence.
    The HEX is attached. Save it and re-name it taking the ".txt" off.
    Code:
    '16F676     PICKIT1 TEST
    ' PORTA 1,2 4, AND 5 ARE THE LED PINS
        @  __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
        ANSEL = %00000000
        CMCON = %00000111
        
        START: 
        'D0 HIGH
        TRISA = %11001111
        PORTA = %00010000
        PAUSE 500
        'D1 HIGH
        TRISA = %11001111
        PORTA = %00100000
        PAUSE 500
        'D2 HIGH
        TRISA = %11101011
        PORTA = %00010000
        PAUSE 500
        GOTO START
    Attached Files Attached Files
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit

    The program worked a treat, many thanks for your time and input on this. I saved the HEX code as Blink.HEX just added .HEX to the end (Doh) and it loaded into the PICKIT1 and then loaded into the PIC and away it ran:

    D0 - D1 - D2 flashing one after the other, brilliant!

    I noticed you wrote the program for the 16F676 PIC yet it ran perfectly on my 12F675 chip, very clever but how does that work? I guess both chips have certain ports and configurations that are common.

    Would it have been possible to have copied the program you wrote and pasted that directly into Microcode Studio - demo and created the HEX file that way? I would like to do this if it can be done to get a feel for converting program code to a HEX file.

    David

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


    Did you find this post helpful? Yes | No

    Default

    It was late, I was tired, I picked the wrong PIC...
    Got lucky that it worked...

    But yes, the code will compile with the demo version if it is for the correct PIC.

    Darn bifocals...
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Couldn't get it to compile, I had:

    Symbol not previously defined Ansel (I had five of these).

    And one: Overwriting previous address contents.

    ANSEL is analogue select right? It's my understanding that your:

    ANSEL = %00000000 code line makes all the pins read in digital, or turn any analogue input off (I think) so can't understand a problem here.

    Also: CMCON = %00000111 puts out decimal 7 which turns the comparitor off? Is that right? This instruction didn't seem to cause a problem.

    Could all this be because the 16F676 PIC wasn't listed when I compiled it? It wasn't in the demo version drop down list.

    Plenty of head scratching going on here, great fun all though, I'll be glad to figure the basics out.

    Dave
    Last edited by LEDave; - 18th February 2010 at 21:41.

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


    Did you find this post helpful? Yes | No

    Default

    What PIC did you pick from th drop down?
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    12F683 The nearest one to the 12F675 (probably doesn't work like that does it?).

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


    Did you find this post helpful? Yes | No

    Default

    This compiles for the 12F683. May not be the correct pins to do the expected, I did not check that.
    Code:
        ANSEL = %00000000
        CMCON0 = %00000111
        
        START: 
        'D0 HIGH
        GPIO = %11001111
        GPIO = %00010000
        PAUSE 500
        'D1 HIGH
        GPIO = %11001111
        GPIO = %00100000
        PAUSE 500
        'D2 HIGH
        GPIO = %11101011
        GPIO = %00010000
        PAUSE 500
        GOTO START
    ANSEL is for turning the ADC on or off. Not clear why it gave an error.
    The CMCON should have though.
    "Overwriting previous address contents" is because I had the fuses set in code and the fuses commented out in the *.inc.
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    Now for some data sheet reading
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Is there a set of code instructions for THE PBP demo version?

    I'm trying to get an understanding of GPIO and the register TRISIO. If you set a TRISIO bit low you make the corresponding GPIO pin an output (I think) Except GP3 which is always an INPUT.

    I've got a very blurred picture of how this all fits together, one day the fog will lift.... I hope.

    Dave

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