• AVR Freaks

pickit 2 with 16f88

Author
crazy_andy
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2007/03/26 16:13:03
  • Location: 0
  • Status: offline
2007/03/30 11:18:11 (permalink)
0

pickit 2 with 16f88

Hey, I bought the pickit 2 programmer, and it just turned up. I wired it up to the pic16f88 as below.
 
http://img267.imageshack.us/img267/5664/icspwz9.jpg
 
I then tried to write to the chip and got the following (same thing with the device powered, and not)
 
http://img267.imageshack.us/img267/1233/pickit2fa0.jpg
 
basically:
 
download firmware to pickit 2
it finds my device and correctly tells me if its powered or not, and that its an 16f88
import hex file
click write / erase
no device found: unsuported device: id: 3FE0
 
same happened with 2 pics, same program.
 
my code: http://www.slexy.org/paste/1972
builds, links and works in mplab
 
configuration bits: http://img130.imageshack.us/img130/6515/configxw4.jpg
 
occasionally the program writes, but part doesn't verify, but not often. And the first time I tried it, it worked and wrote and verified. But the program in the chip didn't work properly. I got the correct initial output, but then it just stayed at that, it could be a timing issue with my loops, such as the chip is running a lot slower than mplabs simulator does (more than likely)
 
finally i ran the troubleshooting wizzard, and besides getting a few shocks, the potential differences where pretty close to expected.
 
Thanks in advance.
 

Attached Image(s)

#1

8 Replies Related Threads

    PICkit2Dev
    Super Member
    • Total Posts : 994
    • Reward points : 0
    • Joined: 2006/09/27 08:41:47
    • Location: 0
    • Status: offline
    RE: pickit 2 with 16f88 2007/03/30 12:37:39 (permalink)
    0
    The problem here is that you've MCLR turned off, and are driving at least one of RB6 and RB7 high or are using Timer1 Osc.  To enter programming mode, the programmer must be able to drive the RB6 and RB7 pins low while applying the programming voltage.  Since MCLR is off, it cannot reset the part so all pins default to inputs, and so the PICkit 2 has to fight with the PORTB driver on those pins, and the PORTB driver usually wins.  (Timer1 Osc also interferes with programming).
    Normally, a trick of pulsing the programming voltage gets around this, but it doesn't seem to be working with the PIC16F88. 

    To avoid programming issues, change your program so either MCLR is enabled or it leaves TRISB<6> and TRISB<7> as inputs (or has an appreciable code delay before Timer1 Osc is enabled.)

    To recover your chips, do the following:

    1) Set the VDD voltage box to 3.0 (Don't use an external power supply, and uncheck the "On" box)
    2) READ the device (if this doesn't work, lower the VDD box by 0.1V until it does)
    3) In the Program Memory display, edit address 0 to the value 0x2800 as shown in the attached picture.
    4) WRITE the device (it will warn you of the low voltage, click "Continue")
    5) Set VDD box = 5.0 volts
    6) ERASE the chip.



    post edited by PICkit2Dev - 2009/02/25 19:20:16

    Attached Image(s)

    #2
    crazy_andy
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2007/03/26 16:13:03
    • Location: 0
    • Status: offline
    RE: pickit 2 with 16f88 2007/03/30 14:51:59 (permalink)
    0
    Thanks for your quick responce,
    I followed your instructions and it worked fine.
     
    However I'm not too sure about what you meant by: "In the meantime, change your program so either MCLR is enabled or it leaves TRISB<6> and TRISB<7> as inputs."
     
    To enable MCLR, is that in the configuration bits of mplab? or the checking the box "/MCLR"
     
    I tried that and the following code instead of clrf TRISB
     
     bcf  PORTB,0    ;pins RB0-RB5 are output
     bcf  PORTB,1
     bcf  PORTB,2
     bcf  PORTB,3
     bcf  PORTB,4
     bcf  PORTB,5
     bsf  PORTB,6    ;pins 6,7 are input
     bsf  PORTB,7
     
    but when I tried to write the program both times, I got errors, as in the image at the bottom. I tried with all combinations of the 2 check boxes.
    The top error was when writing (the write failed the verification)
    The bottom one was trying to import a hex file (not too sure what the problem there is)
     
    Is there a way to totally avoid this problem? As i don't really need icsp, as i move the chip to a different area for testing anyway.
     
    Thanks again for your help its a relief to know I havn't totally destroyed my chips (I hope) just yet.

    Attached Image(s)

    #3
    PICkit2Dev
    Super Member
    • Total Posts : 994
    • Reward points : 0
    • Joined: 2006/09/27 08:41:47
    • Location: 0
    • Status: offline
    RE: pickit 2 with 16f88 2007/03/30 15:39:25 (permalink)
    0
    Pin 4 of the PIC16F88 can be used either as an external reset, or as a digital input RA5 as part of PORTA.  Which function it is is determined by the configuration bits.  Currently, your code has it as RA5, with the Reset function disabled:
    __CONFIG    _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO

    To enable the Reset function, change the configuration definition:
    __CONFIG    _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO

    The MCLR checkbox on the GUI asserts the /MCLR signal to PIN 4 low (reset active) when checked, and leaves the signal tri-stated when unchecked, so a target board pullup can de-assert MCLR.  The 18-pin Demo Board doesn't have a pullup, so if you decide to do this you should add one (10K from Pin 4 to VDD) Essentially, it allows the user to hold the device in reset and release it.


    As for the RB7/RB7 input issue:
    The TRISB bits must be used to set inputs & outputs, not the PORTB bits.  Ensure that you are setting the bits in the correct bank.  The following code changes in red will work:

    main
    ; remaining code goes here

        banksel PORTA    ;select bank 0
        clrf    PORTA    ;clear portA
        clrf    PORTB    ;clear portB

        banksel TRISA    ;select bank 1
        clrf    TRISA    ;portA = output
        movlw   0xC0
        movwf   TRISB    ;portB 5:0 = output, 7:6 = input
        clrf    ANSEL    ;all inputs digital (not that we have inputs but meh)

    An important note on ANSEL : It is important to set ANSEL before doing any BCF or BSF instructions on ports.  That is because these instructions are read-modify-write, and if a port pin is set for analog it will always read as 0.  Thus, if RB6 is analog, and you do
    BSF   PORTB, 6 - will set PORTB, 6
    BSF   PORTB, 7 - the "read" reads RB6=0, the modify sets bit 7, and the write (entire byte) will CLEAR RB6, and set RB7.  So might expect RB6 to still be set, but it is not.

    Finally: "banksel"
    This is a handy macro built into MPASM that sets the STATUS RP bits appropriately for the register argument following (if it has been defined with the complete 9-bit addres, which the INC file does).  There is no include or other definition needed; just use it as above.
    Note that this is not relevant to the problems you are having, I'm just passing it along as a suggestion.
    post edited by PICkit2Dev - 2007/03/30 15:44:01
    #4
    crazy_andy
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2007/03/26 16:13:03
    • Location: 0
    • Status: offline
    RE: pickit 2 with 16f88 2007/03/30 16:24:19 (permalink)
    0
    Cheers again, that cleared some stuff up.

    The bcf, bsf on portb was a typo, I meant to do it on trisb.

    I know about banksel, but since it was defined deprecated i thought I should avoid it, as I'm fairly sure our project is going to require more advanced chips in the future.

    Since my last post, I managed to get the code to write correctly at 3v and with some timer adjustments I can confirm my chip, code and programmer do work. Soon as i get it working 100% I'll be very happy.

    Thanks for all your time and effort, you spent helping me, and the coding in general, its much appreciated.
     
    EDIT:
    I turned mclr on, and changed it back to clrf TRISB, and still getting the same prob, it burns at 3v, but not at 5. I get verification errors at both voltages.
    post edited by crazy_andy - 2007/03/30 17:14:40
    #5
    PICkit2Dev
    Super Member
    • Total Posts : 994
    • Reward points : 0
    • Joined: 2006/09/27 08:41:47
    • Location: 0
    • Status: offline
    RE: pickit 2 with 16f88 2007/03/30 18:55:57 (permalink)
    0
    The 16F88 cannot be programmed at 3v.  It must be programmed with VDD at least 4.5 Volts in order to erase properly.
    (At below 4.5V, it won't erase, but bits that are still '1' can be set to zero - that's why address zero can be set to "2800", which is a GOTO 0 opcode that keeps it looping at the first instruction, preventing it from getting to the code that sets the ICSP pins to outputs.)

    Recover and erase the chip using the steps above, then program new code at 5V.  Check that your PICkit 2 is indeed providing more than 4.5V.  Some USB ports may have a low voltage, preventing PICkit 2 from being able to provide at least 4.5V.  If this is the case, use an external supply to provide 5V VDD to the target board.
     
    If you are still encountering problems, please email me using the button below.
    post edited by PICkit2Dev - 2007/03/30 21:51:46
    #6
    crazy_andy
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2007/03/26 16:13:03
    • Location: 0
    • Status: offline
    RE: pickit 2 with 16f88 2007/03/31 02:32:28 (permalink)
    0
    thanks again, will give it another test, and see what I can do. If not I'll e-mail you.
    #7
    crazy_andy
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2007/03/26 16:13:03
    • Location: 0
    • Status: offline
    RE: pickit 2 with 16f88 2007/04/01 12:20:41 (permalink)
    0
    Hey, I e-mailed you but havn't had a responce as of yet, can you confirm you received it?
    #8
    PICkit2Dev
    Super Member
    • Total Posts : 994
    • Reward points : 0
    • Joined: 2006/09/27 08:41:47
    • Location: 0
    • Status: offline
    RE: pickit 2 with 16f88 2007/04/02 10:16:12 (permalink)
    0
    The final resolution to the other problems discussed in this thread was a bad connection on VSS between PICkit 2 and the target board.  Correcting that fixed the symptomatic issues discussed above.
     
    (Note that an issue still exists with programming the 16F88 with both /MCLR Off and RB6 and/or RB7 set to output driving high)
    #9
    Jump to:
    © 2019 APG vNext Commercial Version 4.5