I can't program my pic16f627a with pickit3

MrChips

Joined Oct 2, 2009
34,824
If you have not programmed in ASM or C, I would suggest starting out with a different MCU, one that is easier to follow. My choice would be TI MSP-EXP430G2ET LaunchPad.
 

trebla

Joined Jun 29, 2019
599
Also, please explain the settings of the IDE to how I route my external 5v power to the Pickit3-target device. How do I make sure I'm seeing the right windows for my current project also?
If you want to use external power for the target PIC device then you must configure IPE power settings to off (do not power target from PicKit3).
To ensure you are seeing current project files in the right window, close all the windows with code and then make right click on the project name in upper left window and choose "Set As Main Project" from dropdown menu, project name should then go bold. Then you can reopen current main.c file from project tree under Source File section.
 

Thread Starter

Arjune

Joined Jan 6, 2018
354
I find assembler much harder than C so I use C exclusively.
I have attached an image of my MPLABX screen. Do you mean the 'Output - Configuration Loading Error' tab that is missing?
If so that appears when first loading MPLABX.
I think you're right, configuration loading error
 

Thread Starter

Arjune

Joined Jan 6, 2018
354
If you have not programmed in ASM or C, I would suggest starting out with a different MCU, one that is easier to follow. My choice would be TI MSP-EXP430G2ET LaunchPad.
I rather try to resolve the current dilemma with the pic
 

Thread Starter

Arjune

Joined Jan 6, 2018
354
I installed a new version of linux (linux mint 22.2 cinnamon). I reinstalled mplabx but it is in opt directory and I don't know how to open it. How do I open the application?
 

Thread Starter

Arjune

Joined Jan 6, 2018
354
I opened mplab ide and ipe under programming. I am including two screenshots of hex file and hex error. Does anyone know how to interpret this?

Screenshot Ronald Arjune HEX.pngScreenshot ronald arjune output.png
 

trebla

Joined Jun 29, 2019
599
The Intel HEX file format is explained here. I tried to reproduce your code with MPLAB X 6.25, unfortunately it does not support PicKit3 anymore and i don't have any pic16f627A chips so i have not actually tested this. But i see difference in hex files, in second line from the end:

Code:
:02400E00783FF9
 

Attachments

Thread Starter

Arjune

Joined Jan 6, 2018
354
The Intel HEX file format is explained here. I tried to reproduce your code with MPLAB X 6.25, unfortunately it does not support PicKit3 anymore and i don't have any pic16f627A chips so i have not actually tested this. But i see difference in hex files, in second line from the end:

Code:
:02400E00783FF9
So should I try replacing your line of hex to my line of hex and then try programming the device? I think I can edit my hex file with my text editor then load the changed hex file. Maybe the LED will be blinking then if flashing succeeds with no error? Am I thinking correctly?
 

trebla

Joined Jun 29, 2019
599
You can try write my hex file to PIC and see if that works, no need to edit your hex file. Also, please look at the newmain.c file, is there same instructions compared to your program?
 

Thread Starter

Arjune

Joined Jan 6, 2018
354
You can try write my hex file to PIC and see if that works, no need to edit your hex file. Also, please look at the newmain.c file, is there same instructions compared to your program?
Your hex file failed and your C program failed also. They said add the CMCON =7; to turn off the comparators before the TRISB3=0;. Can you build the program again with the CMCON = 7; (the instruction difference) line and produce the hex file and let me know it so I can try it?
 

MrChips

Joined Oct 2, 2009
34,824
You cannot just edit a hex file and expect it work.
Each line of the hex file is there for a purpose. Plus, there are checksums in the line.
 

Thread Starter

Arjune

Joined Jan 6, 2018
354
How do you feed power to the PIC during programming?
I have a 5v power supply with a 7805 regulator going to the power pin of the PIC and connected to VDD of the pickit3 and ground. The low voltage LVP pin is unconnected. I measured the voltage for fluctuations during flashing and there is none. There is no pull up resistor from pin 1 MCLR to VDD....I added a 10K pull up resistor. Programming still fails. I get this message from the ide output:Some of the files in this Project "Ron-pic project A1" contain spaces or odd characters in their name or their path. This could potentially cause issues during the build process. This is a limitation of GNU Make tool that we use as part of our build process. Removing spaces from all file and folder names included in this project will eliminate this potential issue.ome of the files in this Project "Ron-pic project A1" contain spaces or odd characters in their name or their path. This could potentially cause issues during the build process. This is a limitation of GNU Make tool that we use as part of our build process. Removing spaces from all file and folder names included in this project will eliminate this potential issue. What does this mean?

Also after adding the (#include <pic16f627a.inc> // Or use __CONFIG as needed) I get these errrors with clean and build:

CLEAN SUCCESSFUL (total time: 102ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make -f nbproject/Makefile-default.mk dist/default/production/Ron-pic_project_A1.X.production.hex
make[2]: *** [nbproject/Makefile-default.mk:104: build/default/production/ron_program_A1.p1] Error 1
make[1]: *** [nbproject/Makefile-default.mk:85: .build-conf] Error 2
make[2]: Entering directory '/home/ronald/MPLABXProjects/Ron-pic project A1.X'
make: *** [nbproject/Makefile-impl.mk:39: .build-impl] Error 2
"/opt/microchip/xc8/v3.10/bin/xc8-cc" -mcpu=16F627A -c -mdfp="/opt/microchip/mplabx/v6.20/packs/Microchip/PIC16Fxxx_DFP/1.6.156/xc8" -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -mno-default-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/ron_program_A1.p1 ron_program_A1.c
In file included from ron_program_A1.c:5:
/opt/microchip/mplabx/v6.20/packs/Microchip/PIC16Fxxx_DFP/1.6.156/xc8/pic/include/proc/pic16f627a.inc:47:1: error: unknown type name 'INDF'
47 | INDF equ 0000h
| ^
/opt/microchip/mplabx/v6.20/packs/Microchip/PIC16Fxxx_DFP/1.6.156/xc8/pic/include/proc/pic16f627a.inc:46:14: note: expanded from macro 'INDF'
46 | #define INDF INDF
| ^
/opt/microchip/mplabx/v6.20/packs/Microchip/PIC16Fxxx_DFP/1.6.156/xc8/pic/include/proc/pic16f627a.inc:47:45: error: expected ';' after top level declarator
47 | INDF equ 0000h
| ^
2 errors generated.
make[2]: Leaving directory '/home/ronald/MPLABXProjects/Ron-pic project A1.X'

BUILD FAILED (exit value 2, total time: 2s)
 
Last edited:

trebla

Joined Jun 29, 2019
599
Removing spaces from all file and folder names included in this project will eliminate this potential issue. What does this mean
Some processes in Linux do not work correctly if filenames or folder names contain spaces or non-US alphabet characters. I use always underscore _ character in filenames if i need separate some parts in this name. Maybe this will be the issue.

Do not include standard PIC header file, for MPLAB X projects is only #include <xc.h> needed (path to actual chip header file is generated automatically in MPLAB X), *.inc files are needed headers for assembler programs, if you use only C then do not include this file. And i suggest make clean build (Clean and Build Main Project) after you are made some changes in your project, this will eliminate unnessesary and potentially conflicting content from your project.

Today, back in my workshop, i copied this project to my Linux machine (Kubuntu) and compiled with the MPLAB X 6.20. Programmed the PIC16F628 old version chip with PicKit3 directly from MPLAB X IDE. Chip is powered from PicKit3, MCLR pin is connected to VDD via 10k resistor and a 100nF capacitor is connected between VDD and VSS pins. I get only warning that the chip ID is incorrect because i programmed the same hex file generated for PIC16F627A to PIC16F628-04 chip. But programming was successful and the LED starts flashing.

If this HEX file i sent to you does not write to chip then this will be caused from:
-bad connections between programmer and chip
-lack of pullup 10k resistor and 100nF capacitor (althrough i was able to program without one)
-confict between onboard power and PicKit power sources, use only one of them in same time
-bad file and folder names in project path
-bad chip
-bad PicKit
 

Thread Starter

Arjune

Joined Jan 6, 2018
354
Some processes in Linux do not work correctly if filenames or folder names contain spaces or non-US alphabet characters. I use always underscore _ character in filenames if i need separate some parts in this name. Maybe this will be the issue.

Do not include standard PIC header file, for MPLAB X projects is only #include <xc.h> needed (path to actual chip header file is generated automatically in MPLAB X), *.inc files are needed headers for assembler programs, if you use only C then do not include this file. And i suggest make clean build (Clean and Build Main Project) after you are made some changes in your project, this will eliminate unnessesary and potentially conflicting content from your project.

Today, back in my workshop, i copied this project to my Linux machine (Kubuntu) and compiled with the MPLAB X 6.20. Programmed the PIC16F628 old version chip with PicKit3 directly from MPLAB X IDE. Chip is powered from PicKit3, MCLR pin is connected to VDD via 10k resistor and a 100nF capacitor is connected between VDD and VSS pins. I get only warning that the chip ID is incorrect because i programmed the same hex file generated for PIC16F627A to PIC16F628-04 chip. But programming was successful and the LED starts flashing.

If this HEX file i sent to you does not write to chip then this will be caused from:
-bad connections between programmer and chip
-lack of pullup 10k resistor and 100nF capacitor (althrough i was able to program without one)
-confict between onboard power and PicKit power sources, use only one of them in same time
-bad file and folder names in project path
-bad chip
-bad PicKit
How do I find the files and paths that I have to remove spaces or odd characters from filenames. I don't know what this is referring to. I have to be sure the project will find the files after removing spaces or odd characters.
 
Last edited:

trebla

Joined Jun 29, 2019
599
How do I find the files and paths that I have to remove spaces or odd characters from filenames.
I hope the installation directory of the MPLAB X is in default location, then there is no problems. Problem may be lay in your project directory. Navigate to your project folder and make right click on the folder name. Depending of the file explorer app there may appear drop-down menu where you can choose to open terminal in this location. In therminal window type in pwd command and you will see full path of this folder. Alternatively just open terminal window and navigate to the project directory with ls -l and cd commands. Usually is the default location for yor project /home/Your_user_name/MPLABXProjects/Your_project_name
 
Top