Re-Programming Problem


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default Re-Programming Problem

    I have a strange problem. Im making a program that I need to use a 32.768khz crystal on the timer1 input to get accurate timing. So I have set up timer1 in this fashion. However this uses the same pins as the programming clock and data and since i have MCLRE off in my config, I cant seem to reprogram the chip.

    I've tried 3 different chips and every time i flash this program onto one of them the program goes on OK but then no matter what I do PicKit2 will not find the chip any more.

    Even taking the chip out of the circuit and connecting it directly to the PicKit2 does not allow it to recognise the chip. Ive tried selecting the chip manually and erasing but it didnt work. The program is still there.

    Im thinking the timer1 configuration is interfering with the communication with the progammer, and becuase MCLR is disabled, pulling MCLR low does not stop the program.

    Does any1 know if there is a way for me to erase these chips cos otherwise they are pretty much dead since the program is not complete.

    config:
    Code:
            __CONFIG    _CONFIG1H, _INTIO2_OSC_1H
            __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _MCLRE_OFF_3H
            __CONFIG    _CONFIG4L, _LVP_OFF_4L
    code:
    Code:
    DEFINE OSC 8
    
    DEFINE LCD_DREG PORTB                               
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB                              
    DEFINE LCD_RSBIT 5
    DEFINE LCD_EREG PORTB                             
    DEFINE LCD_EBIT 4
    DEFINE LCD_BITS 4                                  
    DEFINE LCD_LINES 2                               
    DEFINE LCD_COMMANDUS 2000                        
    DEFINE LCD_DATAUS 50                         
    
    OSCCON.4=1       ' 8Mhz Internal Clock
    OSCCON.5=1
    OSCCON.6=1
    
    ADCON0=%00000000 ' ADC off
    ADCON1=%01111111 ' All I/O digital
    
    T0CON=%10010111  ' Timer0: 16-bit, 1:256 scaler, 1=128uS, 1sec=7813 
    T1CON=%00001111  ' Timer1: 16-bit, 32.768 kHz external clock, $FFFF=2 sec
    
    RF_IN       VAR PORTA.7
    SOLENOID    VAR PORTA.2
    LED         VAR PORTA.3
    UP          var PORTA.1
    DOWN        var PORTA.4
    ENTER       VAR PORTA.5
    BLANK1      VAR PORTA.0
    BLANK2      VAR PORTA.6
                           
    pulse       var word
    temp        var word
    hours       var byte
    mins        var byte
    
    input RF_IN
    INPUT UP
    INPUT DOWN
    INPUT ENTER
    INPUT BLANK1
    INPUT BLANK2
    
    LOW SOLENOID
    HIGH LED
    
    hours=0
    mins=0
    
    PAUSE 500
    
    LED=0
    
    
    main:
    gosub set_time
    ' Rest of the program to go here
    end
    
    
    
    set_time:
    LCDOUT $FE,1,$FE,2,"   Set Hours"
    LCDOUT $FE,$C0,"     ",dec2 hours,":",DEC2 mins
    set_time_loop:
    IF UP=1 then
        gosub wait_release
        hours=hours+1
        if hours=24 then hours=0
        LCDOUT $FE,$C0,"     ",dec2 hours,":",DEC2 mins
    endif
    IF DOWN=1 then
        gosub wait_release
        hours=hours-1
        if hours=255 then hours=23
        LCDOUT $FE,$C0,"     ",dec2 hours,":",DEC2 mins
    endif
    IF ENTER=1 then
        gosub wait_release
        LCDOUT $FE,1,$FE,2
        RETURN
    endif
    goto set_time_loop
    
    
    wait_release:
    pause 20
    waitloop:
    if UP=1 or DOWN=1 or ENTER=1 then goto waitloop
    pause 20
    return
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    How are those chips called ??? ...

    That would certainly help to know it ...

    did you test your Pickit with a "valid" chip after that ??? to be sure there's no problem on its side.

    Also have a look to the Microchip " Midrange manual " $ 28 ( ICSP Programming )

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

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    sorry, they are 18F1320 chips.

    Ive tested the programmer with other chips on different programs it it works, it just as soon as I program this program to a chip its stuck there for good. Ive fixed the program by re-enabling MCLR so that the programmer can stop the program.

    But ive still got 3 PIC chips that have the un-fixed program and cant seem to clear them.

    i'll have a look for the Midrange manual u mentioned
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Unhappy Alredy seen ... halas.

    Ahhh,

    18F1320 ...

    I had reprogramming problems with some of them ( still have one which definitly "locked" after ~ 20 reprogrammings ) Thread posted here.

    The second one took service back two Picstart plus revisions later...

    Batch is 05250SE ...

    Tried three programmers : Picstart+, ICD2 and a ( trustable ) "custom one" ... same behaviour.


    Microchip never answered anything about that ...

    Soooo, I'd encourage you to turn to another pin for pin compatible chip ( 16F88 i.e. ... )

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

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I don't think that's the issue. I did this test: Grabbed a brand new, never used 18F1320 and programmed and old program on it and it worked, programmed a different program and it worked, then programmed the program posted in my OP and now the chip cant be read by PicKit2. The program runs, but I cant change or erase it.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default

    I was just reading a thread on another forum ...
    http://www.electro-tech-online.com/m...1320-dead.html

    They came to the conclusion that erasing it with a JDM type programmer seemed to work, when the PICkit2 wouldn't..
    <br>
    DT

  7. #7
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Nice work as usual Darrel. This is exactly the problem I am having. I did google it but I guess I wasnt using the right key words.

    So I guess the moral of the story is: 18F1320+TMR1(w/ext clock)+MCLRE_OFF = bad

    Too bad I dont have a JMD programmer. I guess i'll see if its worth building one just to revive these 3 PIC chips.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    I have found that a Microchip ICD2 can program any part - properly (and can debug too). Even though it costs more, the time saved in debugging a programmer problem is worth it. And it programs EVERY PIC.
    Charles Linquist

  9. #9
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I borrowed a JMD programmer from a friend to try to erase these PICs but no luck. After doing the erase procedure and also trying programming a working program neither worked. If I apply power to the PICs after all of that I see that they still have the program on them that stuffed them up.

    Is it just me, or does it seem like bad design on behalf of microchip if disabling MCLR and setting Timer 1 to external clock will create a program that cannot be erased from the PIC?
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  10. #10
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I finally solved it.

    I found this very useful snippet in the PICkit2's User's Guide:

    Use VPP First Program Entry - When checked, it allows the PICkit 2 to connect to and program devices with configurations and code that interferes with the ICSP signal pins, preventing PICkit 2 from detecting them.
    Once I set that, they erased like a dream. So three 18F1320's saved from the trash
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default

    You read the User's Guide?

    <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3299&stc=1&d=123889082 4" /><!-- Name:  Clapping.gif
Views: 270
Size:  2.2 KB -->

    Wish I'd done that
    <br>
    DT

Similar Threads

  1. Programming Problem PIC12F683
    By StoneColdFuzzy in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 2nd June 2009, 21:39
  2. 16F676 programming problem
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th May 2009, 17:39
  3. PIC18F4620 Programming problem
    By JavPar in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 6th December 2008, 04:21
  4. Programming Problem with PIC16F819
    By Dick Ivers in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 24th July 2007, 18:42
  5. Problem programming the PIC16F648A
    By Edgardo_2 in forum General
    Replies: 2
    Last Post: - 29th December 2006, 00:02

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