Problem verifying that my new PICKit4 is working properly
Posted: Sun Jan 23, 2022 10:09 pm
Hi, Ric. The Microchip Forum firewall won't let me post. I got frustrated and came here for help. If, I do not have this thread in the correct topic, please feel free to move it.
RE:
PIC12F1840 – Brand New
MPLab X = v5.50
XC8 = v2.32
OS = Windows 10
Programmer = Brand New PICKit4
Novice C coding skills
Novice MPLab X/XC8 skills
The Problem
I am having trouble verifying that my new PICKit4 Programmer is operating properly. I am rather confident that it is a code issue, but, because the PK4 was not cheap, I want to be confident that everything is working exactly as it should...
The Condition
My code is intended to blink LEDs on Pins 5, 6 and 7… Each for ½ second on - ½ second off, in sequence and continuously. What I am getting is that Pin 7 is illuminating for the full three seconds, blinks off and repeats. Meaning, Pins 5 and 6 are not illuminating, at all.
What I Have Done
I am aware that certain PICKit4 properties must be manually set. So, while initially creating the project, I plugged in the PICKit4 (the PK4 was recognized) and set the
- Tools Properties to Low Voltage.
- Power Properties to power the Target at 5 volts.
- Applied changes.
Then, I
- Set all of the typical project properties. The project does default to Main Project, correctly.
- Created the main and config_bits pages in the Source Folder.
- Copied the config_bits.c page, from a prior project, pasted it into Note Pad, to wash it of any formatting, and copied/pasted onto its tab page.
- Copied the main.c page, from a prior project, pasted it into Note Pad, to wash it of any formatting, and copied/pasted it onto its tab page.
- Adjusted/simplified the to just blink the said pins.
Clean and Build
The project builds successfully, with various complaints that I have learned (previously) are non-consequential.
Make and Program Device
The flash completes and verifies.
So, what am I missing? Thank you for your help!
I ran the Clean and Build again, to get this…
RE:
PIC12F1840 – Brand New
MPLab X = v5.50
XC8 = v2.32
OS = Windows 10
Programmer = Brand New PICKit4
Novice C coding skills
Novice MPLab X/XC8 skills
The Problem
I am having trouble verifying that my new PICKit4 Programmer is operating properly. I am rather confident that it is a code issue, but, because the PK4 was not cheap, I want to be confident that everything is working exactly as it should...
The Condition
My code is intended to blink LEDs on Pins 5, 6 and 7… Each for ½ second on - ½ second off, in sequence and continuously. What I am getting is that Pin 7 is illuminating for the full three seconds, blinks off and repeats. Meaning, Pins 5 and 6 are not illuminating, at all.
What I Have Done
I am aware that certain PICKit4 properties must be manually set. So, while initially creating the project, I plugged in the PICKit4 (the PK4 was recognized) and set the
- Tools Properties to Low Voltage.
- Power Properties to power the Target at 5 volts.
- Applied changes.
Then, I
- Set all of the typical project properties. The project does default to Main Project, correctly.
- Created the main and config_bits pages in the Source Folder.
- Copied the config_bits.c page, from a prior project, pasted it into Note Pad, to wash it of any formatting, and copied/pasted onto its tab page.
- Copied the main.c page, from a prior project, pasted it into Note Pad, to wash it of any formatting, and copied/pasted it onto its tab page.
- Adjusted/simplified the to just blink the said pins.
Clean and Build
The project builds successfully, with various complaints that I have learned (previously) are non-consequential.
Make and Program Device
The flash completes and verifies.
So, what am I missing? Thank you for your help!
- Code: Select all
/*
**********************************
* File: config_bits.c
* Author: xxx
*Tees_12F1840_PICKit4_Test
* Created on January 23, 2022; 12:08pm
* (C) All Rights Reserved
* Configuration Bits
*********************************
*/
// CONFIG1
#pragma config1 FCMEN = OFF // Failsafe clock monitor disabled
#pragma config1 IESO = OFF // Internal/external clock switchover disabled
#pragma config1 CLKOUTEN = OFF // Clock out enable off
#pragma config1 BOREN = OFF // Brown-out reset disabled
#pragma config1 CPD = OFF // Data code protection off
#pragma config1 CP = OFF // Code protection off
// #pragma config1 MCLRE = [INGORED/1Input] // If Low Voltage Programming is enabled, this bit is ignored.
#pragma config1 PWRTE = OFF // Power up timer disabled
#pragma config1 WDTE = OFF // Watchdog timer off
#pragma config1 FOSC = INTOSC // Internal oscillator, I/O on GP4 and GP5
// CONFIG2
#pragma config2 LVP = ON // Low-voltage programming enabled
#pragma config2 DEBUG = OFF // In-Circuit Debugger disabled, ICSPCLK and ICSPDAT are general purpose I/O pins
// #pragma config2 UNIMPLEMENTED = 1 // Coded per DS instructions
// #pragma config2 BORV = 1 // Brown-out reset voltage selection = low trip point
#pragma config2 STVREN = OFF // Stack over/under reset disabled
#pragma config2 PLLEN = OFF // Phase Lock Loop disabled
// #pragma config2 UNIMPLEMENTED = 111 // Bit 7-5 Coded per DS instructions
// #pragma config2 RESERVED = 1 // Bit 3-2 Coded per DS instructions
// #pragma config2 UNIMPLEMENTED = 11 // Coded per DS instructions
#pragma config2 WRT = OFF // Flash memory self-write protection disabled
- Code: Select all
/*
* File: main.c
* Author: xxx
*Tees_12F1840_PICKit4_Test
* Created on January 23, 2022; 12:08pm
* (C) All Rights Reserved
*/
/* The purpose of this project is to investigate the operation of my new PICKit4 Programmer. A Microchip
* PIC12F1840 is used to perform a typical "Blink Test" as follows:
LED1 = On Pin 7
LED2 = On Pin 6
LED3 = On Pin 5
Explanations of a Blink Test, for both coding and hardware arrangement, shall not be
* included, here, as extensive tutorials are readily available on the Internet. */
#include <xc.h>
// Declarations
void resetPinState();
void led1on();
void led2on();
void led3on();
// Definitions
void resetPinState() // Set Pin states as Inputs in order to turn the pins off.
{
TRISAbits.TRISA0 = 1; // Pin 7
TRISAbits.TRISA1 = 1; // Pin 6
TRISAbits.TRISA2 = 1; // Pin 5
}
void led1on() {
LATA = 0b00001; // 0 high = Pin 7
TRISAbits.TRISA0 = 0; // LED1 illuminated
}
void led2on() {
LATA = 0b00010; // 1 high = Pin 6
TRISAbits.TRISA1 = 0; // LED2 illuminated
}
void led3on() {
LATA = 0b00100; // 2 high = Pin 5
TRISAbits.TRISA2 = 0; // LED3 illuminated
}
void main(void) {
// Default pin configuration for GPIO pins is Input, therefore terminating unused pins as Inputs is not necessary.
// To clear pins used to drive LEDs
resetPinState();
// Sets Internal Oscillator Frequency to 125KHz.
OSCCONbits.IRCF = 0b001;
#define _XTAL_FREQ 125000 // The use of __delay_ms (xxx); requires that the oscillator frequency must be
// specifically defined.
while (1) {
// Flash the LEDs, in sequence, continuously.
led1on();
__delay_ms(500);
resetPinState();
__delay_ms(500);
led2on();
__delay_ms(500);
resetPinState();
__delay_ms(500);
led3on();
__delay_ms(500);
resetPinState();
__delay_ms(500);
}
}
I ran the Clean and Build again, to get this…
- Code: Select all
CLEAN SUCCESSFUL (total time: 112ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/t1dun/Documents/HP Compaq/Documents/PICKit2and4/PICKit4/PICKit4 Test/PICKit4_Test.X'
make -f nbproject/Makefile-default.mk dist/default/production/PICKit4_Test.X.production.hex
make[2]: Entering directory 'C:/Users/t1dun/Documents/HP Compaq/Documents/PICKit2and4/PICKit4/PICKit4 Test/PICKit4_Test.X'
"C:\Program Files\Microchip\xc8\v2.32\bin\xc8-cc.exe" -mcpu=12F1840 -c -mdfp="C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/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 -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/main.p1 main.c
"C:\Program Files\Microchip\xc8\v2.32\bin\xc8-cc.exe" -mcpu=12F1840 -c -mdfp="C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/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 -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -o build/default/production/config_bits.p1 config_bits.c
Non line specific message::: warning: (1020) unknown attribute "CONFIGPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 186
Non line specific message::: warning: (1020) unknown attribute "IDLOCPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 197
Non line specific message::: warning: (1020) unknown attribute "CONFIGPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 186
Non line specific message::: warning: (1020) unknown attribute "IDLOCPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 197
"C:\Program Files\Microchip\xc8\v2.32\bin\xc8-cc.exe" -mcpu=12F1840 -Wl,-Map=dist/default/production/PICKit4_Test.X.production.map -DXPRJ_default=default -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8" -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall -std=c99 -gdwarf-3 -mstack=compiled:auto:auto -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/PICKit4_Test.X.production.elf build/default/production/main.p1 build/default/production/config_bits.p1
Non line specific message::: warning: (1020) unknown attribute "CONFIGPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 186
Non line specific message::: warning: (1020) unknown attribute "IDLOCPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 197
Non line specific message::: warning: (1020) unknown attribute "CONFIGPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 186
Non line specific message::: warning: (1020) unknown attribute "IDLOCPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 197
Non line specific message::: warning: (1020) unknown attribute "CONFIGPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 186
Non line specific message::: warning: (1020) unknown attribute "IDLOCPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 197
Non line specific message::: warning: (1020) unknown attribute "CONFIGPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 186
Non line specific message::: warning: (1020) unknown attribute "IDLOCPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 197
Non line specific message::: warning: (1020) unknown attribute "CONFIGPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 186
Non line specific message::: warning: (1020) unknown attribute "IDLOCPROG" in chipinfo file "C:/Users/t1dun/.mchp_packs/Microchip/PIC12-16F1xxx_DFP/1.3.90/xc8\pic\dat\ini\12f1840.ini" at line 197
Memory Summary:
Program space used 6Bh ( 107) of 1000h words ( 2.6%)
Data space used 3h ( 3) of 100h bytes ( 1.2%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
Configuration bits used 0h ( 0) of 2h words ( 0.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
make[2]: Leaving directory 'C:/Users/t1dun/Documents/HP Compaq/Documents/PICKit2and4/PICKit4/PICKit4 Test/PICKit4_Test.X'
make[1]: Leaving directory 'C:/Users/t1dun/Documents/HP Compaq/Documents/PICKit2and4/PICKit4/PICKit4 Test/PICKit4_Test.X'
BUILD SUCCESSFUL (total time: 9s)
Loading code from C:/Users/t1dun/Documents/HP Compaq/Documents/PICKit2and4/PICKit4/PICKit4 Test/PICKit4_Test.X/dist/default/production/PICKit4_Test.X.production.hex...
Program loaded with pack,PIC12-16F1xxx_DFP,1.3.90,Microchip
Loading completed