I try this code, worked in PROTEUS, but don't work on MCU.
Code: Select all
void wdt_reset() {
asm CLRWDT;
}
void main() {
OSCCON = 0b01011010; // OSC internal @1MHz
ANSELA = 0b00000101; // Configure AN pins as digital - RA0=1 is ADC0 and RA2=1 is DAC1 for another use
ANSELC = 0; // Configure AN pins as digital
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
OPA1EN_bit = 0; // Disable OpAmp
OPA2EN_bit = 0;
TRISA = 0b00000101; // RA0=1 pins is input for ADC0 and RA2=1 is output (set 1) for DAC1 - ignore this
TRISC = 0b00000000; // All pins is output
LATC = 0x01; // All RC pins sets to low - LED1 to RC0
Unlock_IOLOCK();
PPS_Mapping_NoLock(_RC3, _OUTPUT, _CCP2);
PPS_Mapping_NoLock(_RC5, _OUTPUT, _CCP1);
Lock_IOLOCK();
PWM1_Remappable_Init(1000); // Set current freq for PWM1 - library BUGGGG
PWM2_Remappable_Init(2000); // Set current freq for PWM1
PWM1_Remappable_Start(); // Start PWM1 - vezi la RunPrg_LED() - library BUGGGG
PWM2_Remappable_Start(); // Start PWM1 - vezi la RunPrg_LED()
PWM1_Remappable_Set_Duty(128); //!!!!!
PWM2_Remappable_Set_Duty(128); //!!!!! - library BUGGGG
//FVRCON.FVREN = 0; // disable Internal Voltage reference
while(1){
wdt_reset(); //
}
}
CONFIG2 : $8008 : 0x1603
Many thanks!