Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] pic programming, MikroC pro, uploading code. Thank you

Status
Not open for further replies.

Karolina_1

Member level 3
Joined
Mar 10, 2017
Messages
67
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Activity points
639
hello friends

i really need help. I am new to PIC. So i have been using pic18f45k22 microcontroller. I created hex file in MikroC Pro. Than i loaded it to Proteus and its working fine.
Next, i wanted to load it into real pic.
I am using PICkit3 and MPLAB IDE V7.76. I connected pins from 1 till 6 to MCLR, Vdd, Vss, PGD, PGC and left 6th pin not connected as pic18f45k22 doesnt have PGM pin.
1. Opened the MPLAB
2. Selected device
3. Ticket on configuration bits
4. Selected programmer as pickit 3
PICkit 3 detected
Connecting to PICkit 3...
Firmware Suite Version...... 01.47.12
Firmware type......................PIC18F
PICkit 3 Connected.
Device ID Revision = 00000005
5. Ticket on(turn on) power target circuit from PIC
6. Program & Verify
Programming...
Programming/Verify complete

Verifying...
Verify complete

7. Blank Checking...
The following memory regions failed blank check:
Program Memory
Address: 00000000 Expected Value: 000000ff Received Value: 00000016
Blank check failed(0000000 meaning pickit was not recognized and connect)

Maybe problem with mikroC pro. maybe i didnt configure pins like MCLR or Watchdog time etc. Maybe these 6 pins from pickit3 not connected correctly to pic18f45k22. or problem with compiler.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
void main() {
     TRISD0_bit = 0;
     ANSELD=0;
 
     do{
     LATD = 0x00;
     Delay_ms(1000);
     LATD = 0xFF;
     Delay_ms(1000);
     }while(1);
}



I would appreciate any help. Thanks in advance :)

ffff.PNG
sdaf.PNG
 

Why are you performing blank check after programming? Just pointless. Of course the flash is not blank.
 

Am i using right sources. As i said pickit3 and MPLAB IDE v8.76. How can i upload the code into pic device. I created hex file. uploaded it into pic. Read from it and exported. And compared these two and they are not same meaning loading program was not correct. when i actually build the circuit its not working. which hardware and software should i use.
 

Hi,

You programmed correctly the code into the PIC.
All is fine.

The problem is the "blank check". Just don't use it
Maybe you misunderstood what it does? It checks if the PIC is empty.
For sure the PIC is not blank, not empty .... this is what it says.

Klaus
 
Why are you using MPLAB to upload the .hex file. PICKIt3 comes with its own Standalone Programming Software. Why don't you use it ?

Blank Check is done after erasing the chip.
 
thanks for your replies, i didnt know what blank check was. but when i actually build the circuit, its not working. maybe bad pic18f45k22. i powered it from 1st MCLR pin, put 8mhz oscillator with capacitors into 13th and 14th pin, connected led to 19th pin and led is not blinking.

Here is hex file:

:1000000016EF00F00000000000EF00F0000000001C
:0A0010000000000000000000F3D71C
:10001C000900F5CFE6FF0006FBE10106F9E112004D
:10002C0095900F013B6B8C6A290E0B6E960E0C6E25
:10003C007F0E0D6E0D2EFED70C2EFCD70B2EFAD785
:10004C00FF0E8C6E290E0B6E960E0C6E7F0E0D6EC7
:10005C000D2EFED70C2EFCD70B2EFAD7E4D7FFD7DC
:020000040030CA
:0D00010032193CFFBF81FF0FC00FE00F4020
:00000001FF

maybe hex file is wrong, code is given above. or faulty pic. maybe faulty pickit3 or wrong software. maybe pickit 6pins are connected wrong. (explained above how i connected) I couldnt figure it out. Any help appreciated. Thank you
 

I'm not spending time reverse engineering a hex file but the actual programming proces seems to have worked correctly. I think the code you wrote is safely inside the PIC and the error when you tried the blank check seems to confirm that - the first word should be '16'.

Simulators rarely observe the configuration bits so I suggest you look there first. Also check for electrical problems such as lack of decoupling capacitors, missing GND/VSS pin connections and the wiring around the crystal.

Brian.
 

I see nothing in your list of actions where you load in the hex file.

The hex file in post 6 works OK when programmed using MPLAB IPE version 3.55 and genuine PICkit3.

Are you using a clone PICkit3 maybe?

I recommend programming using stand-alone MPLAB IPE, not MPLAB IDE
 

maybe pickit 6pins are connected wrong

If PICKIt3 connections were wrong then you would not get successful PICKit3 communication messages.

Please zip and post your complete mikroC PRO PIC project files and Proteus file. What development board are you using ?

Which version of mikroC PRO PIC are you using ?
 

Thanks i sent you. I am using latest version of mikroC. I was thinking maybe pickit3 doesnt support pic18f45k22. Can it be a case.
 

I powered it from 1st MCLR pin, put 8mhz oscillator with capacitors into 13th and 14th pin, connected led to 19th pin and led is not blinking.
??? MCLR/VPP is not the power pin. Must supply VDD pins 11 and 32. Please show your complete circuit.

To simplify the test setup, you can run the PIC from internal oscillator. One possible error cause less.

MPLAB configuration tells you which programmers are supported for 45K22. PICkit3 is.

- - - Updated - - -

Proteus simulation schematic doesn't show the VDD and VSS pins, but they must be connected in real hardware.
 
Thanks i sent you. I am using latest version of mikroC. I was thinking maybe pickit3 doesnt support pic18f45k22. Can it be a case.

PICkit3 does support PIC18F45K22. I programmed one using genuine PICkit3, your hex file and MPLAB IPE. The LED flashed at 0.5 Hz as expected.

- - - Updated - - -

In case it helps....

Schematic of the devolpment board that I used is here: https://forum.hobbycomponents.com/viewtopic.php?f=44&t=1345 - except that I replaced the MCU for PIC18F45K22

Your ICSP wiring should match....
 
sdaf.PNG this i external hardware i built.

I dont have PICkit3 with me now so i will reprogram and try it on Monday. I will power from Vdd only and ground Vss and MCLR pin will be disabled. I will share the results with here. Thanks everyone. Have a nice weekend.
 

Your schematic looks good, except that you do not show power connections - both VDD pins must be connected to +5V and both Vss pins must be connected to common ground.

You need to connect at least 5 wires from PICkit 3 to PIC. the PGM wire is not needed for this PIC, but best to connect all 6 wires in case you change PIC.

You do not show capacitor values next to crystal, but these should be both 22pF or 33pf. or anywhere between.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top