I have a PIC16F18076 microcontroller that I have been trying to get working and it simply has been working very inconsistently or not a all. I'm programming it using MplabX IDE and a Pickit 4, the device always programs just fine and the Pickit always verifies the correct device is attatched.
All and all I just can't seem to get the thing to ever function as intended. Sometimes I program it to just turn an led on and keep it on but it can't seem to do it consistently, and sometimes it can take several seconds before the LED even turns on at all. I have a more complex program that I download to it when the tester seems to be working better, and that program begins with blinking an LED and the controller shows no signs of wanting to do anything at all.
I thought that maybe I had messed up something internally in the controller but buying new ones did not solve the problem either. I'm assuming my wiring is fine because the LED will light up occasionally, maybe its my code? I'll paste the beginning of the program here:
#include "mcc_generated_files/system/system.h"
/*
Main application
*/
void setlow(void){
II_SetLow();
love_SetLow();
want_SetLow();
when_SetLow();
we_SetLow();
you_SetLow();
your_SetLow();
make_SetLow();
to_SetLow();
kiss_SetLow();
hug_SetLow();
me_SetLow();
hot_SetLow();
so_SetLow();
dance_SetLow();
smile_SetLow();
happy_SetLow();
cute_SetLow();
body_SetLow();
much_SetLow();
laugh_SetLow();
}
int main(void)
{
SYSTEM_Initialize();
// If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
// If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts
// Use the following macros to:
// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable();
// Disable the Global Interrupts
//INTERRUPT_GlobalInterruptDisable();
// Enable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptEnable();
// Disable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptDisable();
int instate;
int wasstate=0;
int safe=0;
heart_SetHigh();
__delay_ms(1000);
heart_SetLow();
__delay_ms(500);
heart_SetHigh();
__delay_ms(1000);
heart_SetLow();
__delay_ms(500);
heart_SetHigh();
__delay_ms(1000);
heart_SetLow();
if(switch_GetValue()){
safe=1;
}
...
The pin under the heart alias is supposed to "beat" at the start of the program but never seems to. Overall I'm just confused on why I can't seem to make the thing work as expected. The lack of consistency is driving me nuts, I'd be happier if the thing consistently didn't work. Any help or ideas are greatly appreciated.
EDITED SCHEMATIC:
simulate this circuit – Schematic created using CircuitLab