mikroC PRO hex file, cant load hex with MPLAB IDE V8.76

How can i load hex code into PIC with pickit3 and mplav ide 8.76

  • PIC

    Votes: 0 0.0%
  • hex

    Votes: 0 0.0%

  • Total voters
    0

Thread Starter

Bakmurat Kubanaliev

Joined Mar 8, 2017
3
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.

C:
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 :)
 

Attachments

Last edited by a moderator:

AlbertHall

Joined Jun 4, 2014
12,636
I may be missing something here but:
Step 6: Program code into the PIC, and verify it is correctly programmed.
Step 7: Check if the PIC is blank and it isn't blank because it is now programmed. This is the expected result.
 

spinnaker

Joined Oct 29, 2009
7,830
Why are you mixing programming environments? Why not use the MikroC IDE to program the device?

Or if you have the code just rewrite it for MPLAB. It should not be that hard.


And you should use MPLabX not MPLab. MPLab has not been supported for sometime now. MPLabX has the MPLab IPE. I believe he old MPLab had a similar tool. In my opinion easier to use than the full IDE, when only dealing with hex files.
 

JohnInTX

Joined Jun 26, 2012
4,787
I have used MPLAB 8.x to load and even debug MikroC programs without issue. As @AlbertHall indicates, it is weird that it blank-checks after programming. It shouldn't do that but since it does, it is correctly reporting that the PIC is not blank.

To check the CONFIG fuses, click Configure->Configuration Bits on the MPLAB 8.x toolbar and verify that the config matches what you want. the settings MikroC doesn't always append the CONFIG bits to the .HEX unless you tell it to do so - and be sure that they are set up in the project configuration.

I actually find that MPLAB 8.x debugs better than MikroC's IDE. Use the .COF file as the MicroC output, load it into MPLAB and you can do source-level debugging. MPLABX does not support .COF

Good luck!
 

Thread Starter

Bakmurat Kubanaliev

Joined Mar 8, 2017
3
Thanks for your replies. It sad to say but when i actually build the circuit its not working. i powered pic from 1st MCRL pin next connected oscillator with capacitors to 13rd and 14st pins. and connected led to 19th RD0 pin. Maybe pickit pins are not connected correctly (explained in the beginning).
code is given above
here is hex file:
Code:
:1000000016EF00F00000000000EF00F0000000001C
:0A0010000000000000000000F3D71C
:10001C000900F5CFE6FF0006FBE10106F9E112004D
:10002C0095900F013B6B8C6A290E0B6E960E0C6E25
:10003C007F0E0D6E0D2EFED70C2EFCD70B2EFAD785
:10004C00FF0E8C6E290E0B6E960E0C6E7F0E0D6EC7
:10005C000D2EFED70C2EFCD70B2EFAD7E4D7FFD7DC
:020000040030CA
:0D00010032193CFFBF81FF0FC00FE00F4020
:00000001FF
 
Last edited by a moderator:

JohnInTX

Joined Jun 26, 2012
4,787
Sort of. At this writing it's waiting for the weekend..
FWIW: I simulated the .HEX in MPLAB 8.63 and it toggles LATD like it should. The CONFIG is unremarkable exceptPLL is set to 4X so it expects the 8MHz to be scaled to 32MHz. For something simple like this, I wouldn't use the PLL.
But like @hexreader and others point out, when you move from sim to hardware, you have to pay attention to the details.
Good Luck.

FWIW redux:
The .PDF is what MPLAB has to say about his config bits.
 

Attachments

Top