Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Can't program a pic - icd2

Status
Not open for further replies.

Marks256

New Member
I think i have everything hooked up right, because MPLAB is able to verify the target, and when i try to program the target, mplab says it was successful;

Code:
Connecting to MPLAB ICD 2
...Connected
ICDWarn0030: MPLAB ICD2 is about to download a new operating system.  If MPLAB IDE is just starting, it will appear to "hang" at the splash screen.  Please be patient.  MPLAB IDE will finish it's intialization after the OS is downloaded.  (Note:  You may wish to select to ignore this warning in the future.)
Downloading Operating System
Connecting to MPLAB ICD 2
...Connected
Setting Vdd source to target
...Reading ICD Product ID
Running ICD Self Test
...Passed
...Download Operating System Succeeded
Setting Vdd source to target
...Reading ICD Product ID
Running ICD Self Test
...Passed
MPLAB ICD 2 Ready
Connecting to MPLAB ICD 2
...Connected
Setting Vdd source to target
...Reading ICD Product ID
Running ICD Self Test
...Passed
MPLAB ICD 2 Ready
Programming Target...
...Erasing Part
Verifying...
...Verify Succeeded
...Programming succeeded
17-Jul-2007, 11:22:28

MPLAB ICD 2 Ready





I am trying to program a PIC16f84a using Bill's (blueroomelectronics) poster. I can't get the LED to do anything! I know for a fact that the LED is in correctly. I copied the circuit exactly, except for the crystal. Since i didn't have a 4MHz crystal, i am using a 3.588513MHz crystal.

I really don't know what i am doing wrong, but this is really making me mad. I just want to see the damn led blink!!!! :D


Here is the code i am trying to execute:

Code:
;*** WDT reset toggles RB0
list p=16F84A
include <p16F84A.inc>
__CONFIG 0x3FF5
org 0
bsf STATUS, RP0
movlw b'00001110'
movwf OPTION_REG
movlw b'11111110'
movwf TRISB
bcf STATUS, RP0
movlw 1
xorwf PORTB, f
sleep
end


with an LED connected to RB0.



Please help. :eek: I just want the led to show some sign of life! :)
 
Hi,
I might be missing something here - but if you have setup as ICD2 why cannot you go into the single step mode or the animate mode to see your code actually running or where its going wrong ?
 
The PIC is programmed. MPLAB verified it.

When you have this problem it is either the config values or your crystal is not working. Could also be bad PIC but that is rare.

MPLAB allows you to over ride the config values in the ASM file. From the main menu select CONFIGURE then CONFIGURATION BITS. Make sure that "Configuration bits set in code" is checked. Not sure what config bits Bill has set but I am sure he got them right.

Could be the crystal is no good or not working with the caps you are using with it. For this sort of thing I like to use a resonator or a PIC with an internal OSC.

Richard:
If he uses the debugger it will just tell him it can not go into the debug mode. Which would be because there is no clock.
 
I couldn't get my PIC12f683's to work either. They have an internal oscillator.

Ugh, this is so frustrating!
 
Marks256 said:
I couldn't get my PIC12f683's to work either. They have an internal oscillator.

Ugh, this is so frustrating!
May be some thing simple. Could be that whatever you are doing wrong you did for both processors.

Did you do a release from reset or disconnect the ICD2 after programming?

Use the debugger instead of the programmer (main menu). If you crystal is working then it will program and then go into the debug mode. If not it will tell you it can not go into debug mode.

Edit: You can not try the debug mode with the PIC12f683. It needs a special adaptor which you do not have.
 
Last edited:
Did you do a release from reset or disconnect the ICD2 after programming?
I just tried and neither of those solutions worked.

Also, it wouldn't let me select the ICD2 as the debuger... I will try to get the 12f683 to work now...
 
Marks256 said:
I just tried and neither of those solutions worked.

Also, it wouldn't let me select the ICD2 as the debuger... I will try to get the 12f683 to work now...

Not so fast. Did you get this message.

ICDWarn0036: MPLAB IDE No longer allows MPLAB ICD 2 to be loaded as a programmer and a debugger simultaneously. Do you wish to unload MPLAB ICD 2 as programmer before loading as a debugger, or do you wish to cancel?

You have to deselect the ICD2 as the programmer first. Then select the ICD2 as the debugger.

If that was not the message what exactly happened?
 
Some of the small pin count PICs can not be ICD debugged without a special adaptor. The datasheet says the 12F683 is one of these.=

Background:
I had more RS232 ICD2s then I needed. I sent one to Mark. I used the inchworm schematic but left off the power supply. It was working when I mailed it. Sort of wish I had sent a target board.

My brain is too toasted to be of much help right now (nap time). Perhaps Bill or another can help. I will be back in about 2 hours.
 
Last edited:
No, i didn't get any errors. Even when i deselect the programmer, it still won't let me debug. :(
 
I honestly don't know what to give for details. :(

Here is a step by step list of what i am doing:

1. Open MPLAB (v7.60)
2. Select programmer by: Programmer > Select Programmer > 2 MPLAB ICD 2
3. Click on the "new" button to bring up an untitled workspace
4. Paste this code in:
Code:
;*** WDT reset toggles RB0
list p=16F84A
include <p16F84A.inc>
__CONFIG 0x3FF5
org 0
bsf STATUS, RP0
movlw b'00001110'
movwf OPTION_REG
movlw b'11111110'
movwf TRISB
bcf STATUS, RP0
movlw 1
xorwf PORTB, f
sleep
end
5. Save the code as an ASM file
6. Click on the the icon in the upper right hand corer to "program target device"
7. Watch as the little yellow LED on the ICD2 blinks :)p)
8. Now i expect it to work? If someone could point me to a good tutorial, that would be fantastic, but i am so confused right now (and my desk is an utter mess...)

What am i doing wrong? :s

Ugh. I think in need a nap now... :)
 
The 16F84A does not have the debugger, it's too old. The 16F88 does.

Sounds like it could be your crystal, the schematics show a resonator (has built in caps) but if you use a 4MHz crystal you have to add 27pf caps between each crystal lead and ground.

It is possible to use a simple RC clock on the 16F84A and change the __CONFIG 0x3FFF

(this enables an RC clock)

Use a 10K resistor and 20pf cap on pin #16 of the 16F84A. (you don't need the crystal so remove it)
**broken link removed**
 
More dumb questions.

I just checked with MPLAB. It will allow you to program a chip even if you have no HEX to program.

It looks like it is programming the chip but all it is doing is setting the config bits.

Did you assemble/build the program ?

If you do VIEW>"Memory Usage Gauge" Does is say 0 RAM 0 ROM ?

If it does you have to use the build ICON to assemble the asm file.
 
3v0... I though it was kinda funny that i didn't have to do anything with the HEX files... :D

I am trying now... ;)
 
I am not sure what to do. I made a project, and added my asm file. Then i clicked on the "build" button, and this comes up:

Code:
Clean: Deleting intermediary and output files.
Clean: Deleted file "C:\Documents and Settings\Dusty\My Documents\Learning PIC\Learning.mcs".
Clean: Done.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F84A "16f84a.asm" /l"16f84a.lst" /e"16f84a.err"
Warning[205] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 2 : Found directive in column 1. (list)
Warning[205] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 3 : Found directive in column 1. (include)
Warning[205] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 4 : Found directive in column 1. (__CONFIG)
Warning[205] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 5 : Found directive in column 1. (org)
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 6 : Found opcode in column 1. (bsf)
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 7 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 8 : Found opcode in column 1. (movwf)
Message[302] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 8 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 9 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 10 : Found opcode in column 1. (movwf)
Message[302] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 10 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 11 : Found opcode in column 1. (bcf)
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 12 : Found opcode in column 1. (movlw)
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 13 : Found opcode in column 1. (xorwf)
Warning[203] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 14 : Found opcode in column 1. (sleep)
Warning[205] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 15 : Found directive in column 1. (end)
Loaded C:\Documents and Settings\Dusty\My Documents\16f84a.cod.
BUILD SUCCEEDED: Tue Jul 17 14:08:37 2007
 
you cut and pasted this

;*** WDT reset toggles RB0
list p=16F628A
include <p16F628A.inc>
__CONFIG 0x3F34
org 0
bsf STATUS, RP0
movlw b'00001110'
movwf OPTION_REG
movlw b'11111110'
movwf TRISB
bcf STATUS, RP0
movlw 1
xorwf PORTB, f
sleep
end

and you should have had this
Code:
;*** WDT reset toggles RB0
  list p=16F628A
  include <p16F628A.inc>
  __CONFIG 0x3F34
  org 0
  bsf STATUS, RP0
  movlw b'00001110'
  movwf OPTION_REG
  movlw b'11111110'
  movwf TRISB
  bcf STATUS, RP0
  movlw 1
  xorwf PORTB, f
  sleep
  end

Column 1 is reserved for labels
 
Solved part of the problem, put a tab in front of all my code (lables in column 1)


Edit: 3v0 beat me to part of the solution...
 
Ugh. More errors

Code:
Make: The target "C:\Documents and Settings\Dusty\My Documents\Learning PIC\16f84a.o" is out of date.
Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F84A "16f84a.asm" /l"16f84a.lst" /e"16f84a.err"
Message[302] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 8 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\DOCUMENTS AND SETTINGS\DUSTY\MY DOCUMENTS\16F84A.ASM 10 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Error: Bad magic number in COFF file "C:\Documents and Settings\Dusty\My Documents\16f84a.cod".
A language-plugin exception occurred and was logged.
BUILD FAILED: Tue Jul 17 14:22:37 2007
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top