PIC12F683 - Error in code compiling

Thread Starter

enciklinux

Joined Dec 8, 2021
13
Hello, I'm quite new into PIC and still learning as I do it.
For starter, I'm trying to copy this guy project "https://www.instructables.com/Mood-vase/"

/* Main.c file generated by New Project wizard
*
* Created: Wed Dec 8 2021
* Processor: PIC12F683
* Compiler: MPLAB XC8
*/

#include <pic.h>
__CONFIG(0x30C4);
/* __________
| \__/ |
Vdd | | Vss
BLUE <| GP5 GP0 |> GREEN
BATT >| GP4 GP1 |> RED
| GP3 GP2 |< LIGHT
|__________|
*/
#define LED1 GPIO5
#define LED2 GPIO0
#define LED3 GPIO1

#define THRESH 254

unsigned char duty1, duty2, duty3;
bit dir1, dir2, dir3;
bit set1, set2, set3;
unsigned char delay1, delay2, delay3;
bit sun, batt, off;

unsigned char pulsecount;

unsigned char seed;
unsigned char softscale;

unsigned char rand(void);
void suncheck(void);

void main() {
// *** config ***

// Oscillator
OSCCON = 0b01110110; // 8MHz clock

// WDT
WDTCON = 0b00010110; // wdt set to max prescale

// Port settings
GPIO = 0b00100011; // port settings
TRISIO = 0b11011100;

// Comparators
CMCON0 = 0b00000111; // Comparators off

// ADC
ANSEL = 0b01011100; // A/D on chanels 2 and 3
ADCON0 = 0b00001001; // start with AN2

// Interrupts
INTCON = 0b11100000; // ADC interrupt

// Timers
OPTION = 0b11000101;

pulsecount = 0;

while(1) {
// *** software PWM ***
if(set1 == 0) {
if(TMR0 >= duty1) {
LED1 = 1;
set1 = 1;
}
}
if(set2 == 0) {
if(TMR0 >= duty2) {
LED2 = 1;
set2 = 1;
}
}
if(set3 == 0) {
if(TMR0 >= duty3) {
LED3 = 1;
set3 = 1;
}
}
}
}


void interrupt isr(void) {
if(T0IF) {
// *** software PWM ***
set1 = 0;
set2 = 0;
set3 = 0;

if(delay1 == 0) {
LED1 = 0;
if(dir1 == 0) {
duty1++;
if(duty1 == 255) {
dir1 = 1;
}
}
else {
duty1--;
if(duty1 == 0) {
dir1 = 0;
delay1 = rand();
suncheck();
}
}
}
else {
if(softscale == 0) {
delay1--;
}
}

if(delay2 == 0) {
LED2 = 0;
if(dir2 == 0) {
duty2++;
if(duty2 == 255) {
dir2 = 1;
}
}
else {
duty2--;
if(duty2 == 0) {
dir2 = 0;
delay2 = rand();
}
}
}
else {
if(softscale == 0) {
delay2--;
}
}

if(delay3 == 0) {
LED3 = 0;
if(dir3 == 0) {
duty3++;
if(duty3 == 255) {
dir3 = 1;
}
}
else {
duty3--;
if(duty3 == 0) {
dir3 = 0;
delay3 = rand();
}
}
}
else {
if(softscale == 0) {
delay3--;
}
}

softscale ++;
if(softscale > 15) {
softscale = 0;
}
T0IF = 0;
}
}

unsigned char rand (void) {
seed = 97 * seed + 133;
return seed;
}

void suncheck(void) {
// *** check for sunlight ***
if(delay1 > 0 && delay2 > 0) {
GODONE = 1;
while(GODONE == 1);
if(ADRESH > THRESH) {
sun = 0;
pulsecount++;
}
else {
sun = 1;
pulsecount = 0;
}

ADCON0 = 0b00001101; // AN3 (BATT)
GODONE = 1;
while(GODONE == 1);
if(ADRESH > 51) {
batt = 0;
}
else {
batt = 1;
}

if(pulsecount > 250) {
off = 1;
}

while(sun == 1 || batt == 0 || off == 1) {
LED1 = 1;
LED3 = 1;

if(batt == 1) {
LED2 = 1;
}
else {
LED2 ^= 1;
}

ADCON0 = 0b00001001; // AN2 (LIGHT)
GIE = 0;
OPTION = 0b11111101; // WDT prescale 1:32
SWDTEN = 1;
SLEEP();

// returning from sleep
GIE = 1;
OPTION = 0b11000101; // Reset settings
SWDTEN = 0;


GODONE = 1;
while(GODONE == 1);
if(ADRESH > THRESH) {
sun = 0;
}
else {
sun = 1;
off = 0;
}

ADCON0 = 0b00001101; // AN3 (BATT)
GODONE = 1;
while(GODONE == 1);
if(ADRESH > 51) {
batt = 0;
}
else {
batt = 1;
}
}
ADCON0 = 0b00001001; // AN2 (LIGHT)
}
}
1638978839663.png
This is the error it does. I tried googling it for hours, but still cannot find my answer.
 
I am having a issue with I am try to program a pic12F683 with and HEX file for a solar charger controller. When I start the application, this found the Pickit programmer and the 12F683. After I try to erase the memory and perform a blank check. Then I select the HEX file and upload it. No error come up and show completed. Now if I try to verify it, an error come up. If I try to read the device after the verify error, the eprom data show all "000" I try to go into the setting and also try for an answer online but I can't find anything. Rebaid
 

sagor

Joined Mar 10, 2019
786
I am having a issue with I am try to program a pic12F683 with and HEX file for a solar charger controller. When I start the application, this found the Pickit programmer and the 12F683. After I try to erase the memory and perform a blank check. Then I select the HEX file and upload it. No error come up and show completed. Now if I try to verify it, an error come up. If I try to read the device after the verify error, the eprom data show all "000" I try to go into the setting and also try for an answer online but I can't find anything. Rebaid
EPROM data will be zero if you don't hard-code something into it. EPROM is not the same as program memory. Program memory on an erased chip will read all "FF".
Check the configuration bits. If you are code protecting the 12F683, you cannot read it back, and any verify may fail.
 
Top