From 3457e3e963d081539e99a54997cfa11dccaabe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Fri, 3 Mar 2023 13:51:01 +0100 Subject: [PATCH] pwm --- solar_panel.X/mcc_generated_files/adc.c | 4 +- solar_panel.X/mcc_generated_files/epwm1.c | 96 +++ solar_panel.X/mcc_generated_files/epwm1.h | 133 ++++ solar_panel.X/mcc_generated_files/mcc.c | 2 + solar_panel.X/mcc_generated_files/mcc.h | 2 + .../mcc_generated_files/pin_manager.c | 2 +- .../mcc_generated_files/pin_manager.h | 8 + solar_panel.X/mcc_generated_files/tmr2.c | 124 ++++ solar_panel.X/mcc_generated_files/tmr2.h | 337 +++++++++++ solar_panel.X/nbproject/Makefile-default.mk | 42 +- .../nbproject/Makefile-genesis.properties | 4 +- solar_panel.X/nbproject/configurations.xml | 7 + .../nbproject/private/configurations.xml | 2 +- solar_panel.X/nbproject/private/private.xml | 8 +- solar_panel.X/solar_panel.mc3 | 566 +++++++++++++++++- 15 files changed, 1312 insertions(+), 25 deletions(-) create mode 100644 solar_panel.X/mcc_generated_files/epwm1.c create mode 100644 solar_panel.X/mcc_generated_files/epwm1.h create mode 100644 solar_panel.X/mcc_generated_files/tmr2.c create mode 100644 solar_panel.X/mcc_generated_files/tmr2.h diff --git a/solar_panel.X/mcc_generated_files/adc.c b/solar_panel.X/mcc_generated_files/adc.c index cadc0f9..d6a7d68 100644 --- a/solar_panel.X/mcc_generated_files/adc.c +++ b/solar_panel.X/mcc_generated_files/adc.c @@ -65,8 +65,8 @@ void ADC_Initialize(void) // VCFG1 VSS; VCFG0 VDD; ADCON1 = 0x00; - // ADFM left; ACQT 0; ADCS FOSC/2; - ADCON2 = 0x00; + // ADFM right; ACQT 0; ADCS FOSC/2; + ADCON2 = 0x80; // ADRESL 0; ADRESL = 0x00; diff --git a/solar_panel.X/mcc_generated_files/epwm1.c b/solar_panel.X/mcc_generated_files/epwm1.c new file mode 100644 index 0000000..96b777e --- /dev/null +++ b/solar_panel.X/mcc_generated_files/epwm1.c @@ -0,0 +1,96 @@ +/** + EPWM1 Generated Driver File + + @Company + Microchip Technology Inc. + + @File Name + epwm1.c + + @Summary + This is the generated driver implementation file for the EPWM1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This source file provides implementations for driver APIs for EPWM1. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F97J60 + Driver Version : 2.01 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +/** + Section: Included Files +*/ + +#include +#include "epwm1.h" + +/** + Section: Macro Declarations +*/ + +#define PWM1_INITIALIZE_DUTY_VALUE 511 + +/** + Section: EPWM Module APIs +*/ + +void EPWM1_Initialize(void) +{ + // Set the EPWM1 to the options selected in the User Interface + + // CCP1M P1A,P1C: active high; P1B,P1D: active high; DC1B 3; P1M single; + CCP1CON = 0x3C; + + // ECCPASE operating; PSSBD P1BP1D_0; PSSAC P1AP1C_0; ECCPAS disabled; + ECCP1AS = 0x00; + + // P1RSEN automatic_restart; P1DC0 0; + ECCP1DEL = 0x80; + + // CCPR1H 0; + CCPR1H = 0x00; + + // CCPR1L 127; + CCPR1L = 0x7F; + +} + +void EPWM1_LoadDutyValue(uint16_t dutyValue) +{ + // Writing to 8 MSBs of pwm duty cycle in CCPRL register + CCPR1L = ((dutyValue & 0x03FC)>>2); + + // Writing to 2 LSBs of pwm duty cycle in CCPCON register + CCP1CON = ((uint8_t)(CCP1CON & 0xCF) | ((dutyValue & 0x0003)<<4)); +} +/** + End of File +*/ + diff --git a/solar_panel.X/mcc_generated_files/epwm1.h b/solar_panel.X/mcc_generated_files/epwm1.h new file mode 100644 index 0000000..8d85909 --- /dev/null +++ b/solar_panel.X/mcc_generated_files/epwm1.h @@ -0,0 +1,133 @@ +/** + EPWM1 Generated Driver File + + @Company + Microchip Technology Inc. + + @File Name + epwm1.h + + @Summary + This is the generated driver implementation file for the EPWM1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This header file provides implementations for driver APIs for EPWM1. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F97J60 + Driver Version : 2.01 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef EPWM1_H +#define EPWM1_H + +/** + Section: Included Files +*/ + +#include +#include + +#ifdef __cplusplus // Provide C++ Compatibility + + extern "C" { + +#endif + +/** + Section: EPWM Module APIs +*/ + +/** + @Summary + Initializes the EPWM1 + + @Description + This routine initializes the EPWM1 module. + This routine must be called before any other EPWM1 routine is called. + This routine should only be called once during system initialization. + + @Preconditions + None + + @Param + None + + @Returns + None + + @Comment + + + @Example + + uint16_t dutycycle; + + ECCP1_Initialize(); + EPWM1_LoadDutyValue(dutycycle); + + */ +void EPWM1_Initialize(void); + +/** + @Summary + Loads 16-bit duty cycle. + + @Description + This routine loads the 16 bit duty cycle value. + + @Preconditions + EPWM1_Initialize() function should have been called before calling this function. + + @Param + Pass 16bit duty cycle value. + + @Returns + None + + @Example + + uint16_t dutycycle; + + EPWM1_Initialize(); + EPWM1_LoadDutyValue(dutycycle); + +*/ +void EPWM1_LoadDutyValue(uint16_t dutyValue); + +#ifdef __cplusplus // Provide C++ Compatibility + + } + +#endif + +#endif //EPWM1_H +/** + End of File +*/ diff --git a/solar_panel.X/mcc_generated_files/mcc.c b/solar_panel.X/mcc_generated_files/mcc.c index cc5c24e..00f5e92 100644 --- a/solar_panel.X/mcc_generated_files/mcc.c +++ b/solar_panel.X/mcc_generated_files/mcc.c @@ -52,6 +52,8 @@ void SYSTEM_Initialize(void) PIN_MANAGER_Initialize(); OSCILLATOR_Initialize(); + EPWM1_Initialize(); + TMR2_Initialize(); ADC_Initialize(); } diff --git a/solar_panel.X/mcc_generated_files/mcc.h b/solar_panel.X/mcc_generated_files/mcc.h index b17c66e..3e771aa 100644 --- a/solar_panel.X/mcc_generated_files/mcc.h +++ b/solar_panel.X/mcc_generated_files/mcc.h @@ -52,6 +52,8 @@ #include #include #include +#include "epwm1.h" +#include "tmr2.h" #include "adc.h" diff --git a/solar_panel.X/mcc_generated_files/pin_manager.c b/solar_panel.X/mcc_generated_files/pin_manager.c index 1d268e7..0d327cb 100644 --- a/solar_panel.X/mcc_generated_files/pin_manager.c +++ b/solar_panel.X/mcc_generated_files/pin_manager.c @@ -71,7 +71,7 @@ void PIN_MANAGER_Initialize(void) TRISG = 0xFF; TRISB = 0xFF; TRISH = 0xFF; - TRISC = 0xFF; + TRISC = 0xFB; TRISD = 0xFF; TRISJ = 0xFF; diff --git a/solar_panel.X/mcc_generated_files/pin_manager.h b/solar_panel.X/mcc_generated_files/pin_manager.h index cae5683..47c5454 100644 --- a/solar_panel.X/mcc_generated_files/pin_manager.h +++ b/solar_panel.X/mcc_generated_files/pin_manager.h @@ -67,6 +67,14 @@ #define PULL_UP_ENABLED 1 #define PULL_UP_DISABLED 0 +// get/set RC2 procedures +#define RC2_SetHigh() do { LATCbits.LATC2 = 1; } while(0) +#define RC2_SetLow() do { LATCbits.LATC2 = 0; } while(0) +#define RC2_Toggle() do { LATCbits.LATC2 = ~LATCbits.LATC2; } while(0) +#define RC2_GetValue() PORTCbits.RC2 +#define RC2_SetDigitalInput() do { TRISCbits.TRISC2 = 1; } while(0) +#define RC2_SetDigitalOutput() do { TRISCbits.TRISC2 = 0; } while(0) + // get/set voltage aliases #define voltage_TRIS TRISFbits.TRISF0 #define voltage_LAT LATFbits.LATF0 diff --git a/solar_panel.X/mcc_generated_files/tmr2.c b/solar_panel.X/mcc_generated_files/tmr2.c new file mode 100644 index 0000000..ede0e87 --- /dev/null +++ b/solar_panel.X/mcc_generated_files/tmr2.c @@ -0,0 +1,124 @@ +/** + TMR2 Generated Driver File + + @Company + Microchip Technology Inc. + + @File Name + tmr2.c + + @Summary + This is the generated driver implementation file for the TMR2 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This source file provides APIs for TMR2. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F97J60 + Driver Version : 2.01 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +/** + Section: Included Files +*/ + +#include +#include "tmr2.h" + +/** + Section: Global Variables Definitions +*/ + +/** + Section: TMR2 APIs +*/ + +void TMR2_Initialize(void) +{ + // Set TMR2 to the options selected in the User Interface + + // PR2 255; + PR2 = 0xFF; + + // TMR2 0; + TMR2 = 0x00; + + // Clearing IF flag. + PIR1bits.TMR2IF = 0; + + // T2CKPS 1:1; TOUTPS 1:1; TMR2ON on; + T2CON = 0x04; +} + +void TMR2_StartTimer(void) +{ + // Start the Timer by writing to TMRxON bit + T2CONbits.TMR2ON = 1; +} + +void TMR2_StopTimer(void) +{ + // Stop the Timer by writing to TMRxON bit + T2CONbits.TMR2ON = 0; +} + +uint8_t TMR2_ReadTimer(void) +{ + uint8_t readVal; + + readVal = TMR2; + + return readVal; +} + +void TMR2_WriteTimer(uint8_t timerVal) +{ + // Write to the Timer2 register + TMR2 = timerVal; +} + +void TMR2_LoadPeriodRegister(uint8_t periodVal) +{ + PR2 = periodVal; +} + +bool TMR2_HasOverflowOccured(void) +{ + // check if overflow has occurred by checking the TMRIF bit + bool status = PIR1bits.TMR2IF; + if(status) + { + // Clearing IF flag. + PIR1bits.TMR2IF = 0; + } + return status; +} +/** + End of File +*/ \ No newline at end of file diff --git a/solar_panel.X/mcc_generated_files/tmr2.h b/solar_panel.X/mcc_generated_files/tmr2.h new file mode 100644 index 0000000..3917213 --- /dev/null +++ b/solar_panel.X/mcc_generated_files/tmr2.h @@ -0,0 +1,337 @@ +/** + TMR2 Generated Driver API Header File + + @Company + Microchip Technology Inc. + + @File Name + tmr2.h + + @Summary + This is the generated header file for the TMR2 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs + + @Description + This header file provides APIs for TMR2. + Generation Information : + Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.8 + Device : PIC18F97J60 + Driver Version : 2.01 + The generated drivers are tested against the following: + Compiler : XC8 2.36 and above + MPLAB : MPLAB X 6.00 +*/ + +/* + (c) 2018 Microchip Technology Inc. and its subsidiaries. + + Subject to your compliance with these terms, you may use Microchip software and any + derivatives exclusively with Microchip products. It is your responsibility to comply with third party + license terms applicable to your use of third party software (including open source software) that + may accompany Microchip software. + + THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER + EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS + FOR A PARTICULAR PURPOSE. + + IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, + INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND + WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP + HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO + THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL + CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT + OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS + SOFTWARE. +*/ + +#ifndef TMR2_H +#define TMR2_H + +/** + Section: Included Files +*/ + +#include +#include + +#ifdef __cplusplus // Provide C++ Compatibility + + extern "C" { + +#endif + + +/** + Section: Macro Declarations +*/ + +/** + Section: TMR2 APIs +*/ + +/** + @Summary + Initializes the TMR2 module. + + @Description + This function initializes the TMR2 Registers. + This function must be called before any other TMR2 function is called. + + @Preconditions + None + + @Param + None + + @Returns + None + + @Comment + + + @Example + + main() + { + // Initialize TMR2 module + TMR2_Initialize(); + + // Do something else... + } + +*/ +void TMR2_Initialize(void); + +/** + @Summary + This function starts the TMR2. + + @Description + This function starts the TMR2 operation. + This function must be called after the initialization of TMR2. + + @Preconditions + Initialize the TMR2 before calling this function. + + @Param + None + + @Returns + None + + @Example + + // Initialize TMR2 module + + // Start TMR2 + TMR2_StartTimer(); + + // Do something else... + +*/ +void TMR2_StartTimer(void); + +/** + @Summary + This function stops the TMR2. + + @Description + This function stops the TMR2 operation. + This function must be called after the start of TMR2. + + @Preconditions + Initialize the TMR2 before calling this function. + + @Param + None + + @Returns + None + + @Example + + // Initialize TMR2 module + + // Start TMR2 + TMR2_StartTimer(); + + // Do something else... + + // Stop TMR2; + TMR2_StopTimer(); + +*/ +void TMR2_StopTimer(void); + +/** + @Summary + Reads the TMR2 register. + + @Description + This function reads the TMR2 register value and return it. + + @Preconditions + Initialize the TMR2 before calling this function. + + @Param + None + + @Returns + This function returns the current value of TMR2 register. + + @Example + + // Initialize TMR2 module + + // Start TMR2 + TMR2_StartTimer(); + + // Read the current value of TMR2 + if(0 == TMR2_ReadTimer()) + { + // Do something else... + + // Reload the TMR value + TMR2_Reload(); + } + +*/ +uint8_t TMR2_ReadTimer(void); + +/** + @Summary + Writes the TMR2 register. + + @Description + This function writes the TMR2 register. + This function must be called after the initialization of TMR2. + + @Preconditions + Initialize the TMR2 before calling this function. + + @Param + timerVal - Value to write into TMR2 register. + + @Returns + None + + @Example + + #define PERIOD 0x80 + #define ZERO 0x00 + + while(1) + { + // Read the TMR2 register + if(ZERO == TMR2_ReadTimer()) + { + // Do something else... + + // Write the TMR2 register + TMR2_WriteTimer(PERIOD); + } + + // Do something else... + } + +*/ +void TMR2_WriteTimer(uint8_t timerVal); + +/** + @Summary + Load value to Period Register. + + @Description + This function writes the value to PR2 register. + This function must be called after the initialization of TMR2. + + @Preconditions + Initialize the TMR2 before calling this function. + + @Param + periodVal - Value to load into TMR2 register. + + @Returns + None + + @Example + + #define PERIOD1 0x80 + #define PERIOD2 0x40 + #define ZERO 0x00 + + while(1) + { + // Read the TMR2 register + if(ZERO == TMR2_ReadTimer()) + { + // Do something else... + + if(flag) + { + flag = 0; + + // Load Period 1 value + TMR2_LoadPeriodRegister(PERIOD1); + } + else + { + flag = 1; + + // Load Period 2 value + TMR2_LoadPeriodRegister(PERIOD2); + } + } + + // Do something else... + } + +*/ +void TMR2_LoadPeriodRegister(uint8_t periodVal); + +/** + @Summary + Boolean routine to poll or to check for the match flag on the fly. + + @Description + This function is called to check for the timer match flag. + This function is used in timer polling method. + + @Preconditions + Initialize the TMR2 module before calling this routine. + + @Param + None + + @Returns + true - timer match has occurred. + false - timer match has not occurred. + + @Example + + while(1) + { + // check the match flag + if(TMR2_HasOverflowOccured()) + { + // Do something else... + + // Reload the TMR2 value + TMR2_Reload(); + } + } + +*/ +bool TMR2_HasOverflowOccured(void); + + #ifdef __cplusplus // Provide C++ Compatibility + + } + +#endif + +#endif // TMR2_H +/** + End of File +*/ + diff --git a/solar_panel.X/nbproject/Makefile-default.mk b/solar_panel.X/nbproject/Makefile-default.mk index b084d5c..c9750c4 100644 --- a/solar_panel.X/nbproject/Makefile-default.mk +++ b/solar_panel.X/nbproject/Makefile-default.mk @@ -57,17 +57,17 @@ OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE} DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE} # Source Files Quoted if spaced -SOURCEFILES_QUOTED_IF_SPACED=lcd/lcd.c mcc_generated_files/device_config.c mcc_generated_files/mcc.c mcc_generated_files/pin_manager.c mcc_generated_files/adc.c main.c crc.c measure.c modbus.c +SOURCEFILES_QUOTED_IF_SPACED=lcd/lcd.c mcc_generated_files/device_config.c mcc_generated_files/mcc.c mcc_generated_files/pin_manager.c mcc_generated_files/adc.c main.c crc.c measure.c modbus.c mcc_generated_files/epwm1.c mcc_generated_files/tmr2.c # Object Files Quoted if spaced -OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/lcd/lcd.p1 ${OBJECTDIR}/mcc_generated_files/device_config.p1 ${OBJECTDIR}/mcc_generated_files/mcc.p1 ${OBJECTDIR}/mcc_generated_files/pin_manager.p1 ${OBJECTDIR}/mcc_generated_files/adc.p1 ${OBJECTDIR}/main.p1 ${OBJECTDIR}/crc.p1 ${OBJECTDIR}/measure.p1 ${OBJECTDIR}/modbus.p1 -POSSIBLE_DEPFILES=${OBJECTDIR}/lcd/lcd.p1.d ${OBJECTDIR}/mcc_generated_files/device_config.p1.d ${OBJECTDIR}/mcc_generated_files/mcc.p1.d ${OBJECTDIR}/mcc_generated_files/pin_manager.p1.d ${OBJECTDIR}/mcc_generated_files/adc.p1.d ${OBJECTDIR}/main.p1.d ${OBJECTDIR}/crc.p1.d ${OBJECTDIR}/measure.p1.d ${OBJECTDIR}/modbus.p1.d +OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/lcd/lcd.p1 ${OBJECTDIR}/mcc_generated_files/device_config.p1 ${OBJECTDIR}/mcc_generated_files/mcc.p1 ${OBJECTDIR}/mcc_generated_files/pin_manager.p1 ${OBJECTDIR}/mcc_generated_files/adc.p1 ${OBJECTDIR}/main.p1 ${OBJECTDIR}/crc.p1 ${OBJECTDIR}/measure.p1 ${OBJECTDIR}/modbus.p1 ${OBJECTDIR}/mcc_generated_files/epwm1.p1 ${OBJECTDIR}/mcc_generated_files/tmr2.p1 +POSSIBLE_DEPFILES=${OBJECTDIR}/lcd/lcd.p1.d ${OBJECTDIR}/mcc_generated_files/device_config.p1.d ${OBJECTDIR}/mcc_generated_files/mcc.p1.d ${OBJECTDIR}/mcc_generated_files/pin_manager.p1.d ${OBJECTDIR}/mcc_generated_files/adc.p1.d ${OBJECTDIR}/main.p1.d ${OBJECTDIR}/crc.p1.d ${OBJECTDIR}/measure.p1.d ${OBJECTDIR}/modbus.p1.d ${OBJECTDIR}/mcc_generated_files/epwm1.p1.d ${OBJECTDIR}/mcc_generated_files/tmr2.p1.d # Object Files -OBJECTFILES=${OBJECTDIR}/lcd/lcd.p1 ${OBJECTDIR}/mcc_generated_files/device_config.p1 ${OBJECTDIR}/mcc_generated_files/mcc.p1 ${OBJECTDIR}/mcc_generated_files/pin_manager.p1 ${OBJECTDIR}/mcc_generated_files/adc.p1 ${OBJECTDIR}/main.p1 ${OBJECTDIR}/crc.p1 ${OBJECTDIR}/measure.p1 ${OBJECTDIR}/modbus.p1 +OBJECTFILES=${OBJECTDIR}/lcd/lcd.p1 ${OBJECTDIR}/mcc_generated_files/device_config.p1 ${OBJECTDIR}/mcc_generated_files/mcc.p1 ${OBJECTDIR}/mcc_generated_files/pin_manager.p1 ${OBJECTDIR}/mcc_generated_files/adc.p1 ${OBJECTDIR}/main.p1 ${OBJECTDIR}/crc.p1 ${OBJECTDIR}/measure.p1 ${OBJECTDIR}/modbus.p1 ${OBJECTDIR}/mcc_generated_files/epwm1.p1 ${OBJECTDIR}/mcc_generated_files/tmr2.p1 # Source Files -SOURCEFILES=lcd/lcd.c mcc_generated_files/device_config.c mcc_generated_files/mcc.c mcc_generated_files/pin_manager.c mcc_generated_files/adc.c main.c crc.c measure.c modbus.c +SOURCEFILES=lcd/lcd.c mcc_generated_files/device_config.c mcc_generated_files/mcc.c mcc_generated_files/pin_manager.c mcc_generated_files/adc.c main.c crc.c measure.c modbus.c mcc_generated_files/epwm1.c mcc_generated_files/tmr2.c @@ -166,6 +166,22 @@ ${OBJECTDIR}/modbus.p1: modbus.c nbproject/Makefile-${CND_CONF}.mk @-${MV} ${OBJECTDIR}/modbus.d ${OBJECTDIR}/modbus.p1.d @${FIXDEPS} ${OBJECTDIR}/modbus.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ +${OBJECTDIR}/mcc_generated_files/epwm1.p1: mcc_generated_files/epwm1.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files" + @${RM} ${OBJECTDIR}/mcc_generated_files/epwm1.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/epwm1.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=snap -mdfp="${DFP_DIR}/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/mcc_generated_files/epwm1.p1 mcc_generated_files/epwm1.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/epwm1.d ${OBJECTDIR}/mcc_generated_files/epwm1.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/epwm1.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/tmr2.p1: mcc_generated_files/tmr2.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files" + @${RM} ${OBJECTDIR}/mcc_generated_files/tmr2.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/tmr2.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -D__DEBUG=1 -mdebugger=snap -mdfp="${DFP_DIR}/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/mcc_generated_files/tmr2.p1 mcc_generated_files/tmr2.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/tmr2.d ${OBJECTDIR}/mcc_generated_files/tmr2.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/tmr2.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + else ${OBJECTDIR}/lcd/lcd.p1: lcd/lcd.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/lcd" @@ -239,6 +255,22 @@ ${OBJECTDIR}/modbus.p1: modbus.c nbproject/Makefile-${CND_CONF}.mk @-${MV} ${OBJECTDIR}/modbus.d ${OBJECTDIR}/modbus.p1.d @${FIXDEPS} ${OBJECTDIR}/modbus.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ +${OBJECTDIR}/mcc_generated_files/epwm1.p1: mcc_generated_files/epwm1.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files" + @${RM} ${OBJECTDIR}/mcc_generated_files/epwm1.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/epwm1.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/mcc_generated_files/epwm1.p1 mcc_generated_files/epwm1.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/epwm1.d ${OBJECTDIR}/mcc_generated_files/epwm1.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/epwm1.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/mcc_generated_files/tmr2.p1: mcc_generated_files/tmr2.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}/mcc_generated_files" + @${RM} ${OBJECTDIR}/mcc_generated_files/tmr2.p1.d + @${RM} ${OBJECTDIR}/mcc_generated_files/tmr2.p1 + ${MP_CC} $(MP_EXTRA_CC_PRE) -mcpu=$(MP_PROCESSOR_OPTION) -c -mdfp="${DFP_DIR}/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=$(CND_CONF) -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits $(COMPARISON_BUILD) -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o ${OBJECTDIR}/mcc_generated_files/tmr2.p1 mcc_generated_files/tmr2.c + @-${MV} ${OBJECTDIR}/mcc_generated_files/tmr2.d ${OBJECTDIR}/mcc_generated_files/tmr2.p1.d + @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/tmr2.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + endif # ------------------------------------------------------------------------------------ diff --git a/solar_panel.X/nbproject/Makefile-genesis.properties b/solar_panel.X/nbproject/Makefile-genesis.properties index ebcc2c3..8b9d6e6 100644 --- a/solar_panel.X/nbproject/Makefile-genesis.properties +++ b/solar_panel.X/nbproject/Makefile-genesis.properties @@ -1,11 +1,11 @@ # -#Tue Feb 28 15:05:35 CET 2023 +#Fri Mar 03 13:24:37 CET 2023 default.languagetoolchain.version=2.40 default.Pack.dfplocation=C\:\\Program Files\\Microchip\\MPLABX\\v6.00\\packs\\Microchip\\PIC18F-J_DFP\\1.5.44 conf.ids=default default.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc8\\v2.40\\bin host.id=3awj-afwq-rl -configurations-xml=15a5d28d4e47d133a748d3cb5ad18cb1 +configurations-xml=080b6b0e67e3ef40b76cf6528cd7e334 default.com-microchip-mplab-mdbcore-snap-SnapToolImpl.md5=eaa336cefb7fc46db8b50b7b2b6e54ca com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=6e02ca5e9f5042ffd365b42ab82d3a9b user-defined-mime-resolver-xml=none diff --git a/solar_panel.X/nbproject/configurations.xml b/solar_panel.X/nbproject/configurations.xml index d57276b..4e9670e 100644 --- a/solar_panel.X/nbproject/configurations.xml +++ b/solar_panel.X/nbproject/configurations.xml @@ -14,6 +14,8 @@ mcc_generated_files/pin_manager.h mcc_generated_files/mcc.h mcc_generated_files/adc.h + mcc_generated_files/epwm1.h + mcc_generated_files/tmr2.h crc.h measure.h @@ -36,6 +38,8 @@ mcc_generated_files/mcc.c mcc_generated_files/pin_manager.c mcc_generated_files/adc.c + mcc_generated_files/epwm1.c + mcc_generated_files/tmr2.c main.c crc.c @@ -175,6 +179,9 @@ + + + diff --git a/solar_panel.X/nbproject/private/configurations.xml b/solar_panel.X/nbproject/private/configurations.xml index 4bfc6de..20b286a 100644 --- a/solar_panel.X/nbproject/private/configurations.xml +++ b/solar_panel.X/nbproject/private/configurations.xml @@ -4,7 +4,7 @@ 0 - :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9018:=<rev>0100:=<man>Microchip Technology Incorporated:=<prod>MPLAB Snap ICD:=<sn>BUR190971825:=<drv>x:=<xpt>b:=end + :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9018:=<rev>0100:=<man>Microchip Technology Incorporated:=<prod>MPLAB Snap ICD:=<sn>BUR190971772:=<drv>x:=<xpt>b:=end C:\Program Files\Microchip\xc8\v2.40\bin place holder 1 diff --git a/solar_panel.X/nbproject/private/private.xml b/solar_panel.X/nbproject/private/private.xml index 6807a2b..4de3a54 100644 --- a/solar_panel.X/nbproject/private/private.xml +++ b/solar_panel.X/nbproject/private/private.xml @@ -2,6 +2,12 @@ - + + file:/C:/Users/remi/Downloads/MCU/solar_panel/solar_panel.X/measure.c + file:/C:/Users/remi/Downloads/MCU/solar_panel/solar_panel.X/measure.h + file:/C:/Users/remi/Downloads/MCU/solar_panel/solar_panel.X/main.c + file:/C:/Users/remi/Downloads/MCU/solar_panel/solar_panel.X/lcd/lcd.c + file:/C:/Program%20Files/Microchip/xc8/v2.40/pic/sources/c99/common/lomod.c + diff --git a/solar_panel.X/solar_panel.mc3 b/solar_panel.X/solar_panel.mc3 index 627c371..7f6f718 100644 --- a/solar_panel.X/solar_panel.mc3 +++ b/solar_panel.X/solar_panel.mc3 @@ -5,6 +5,10 @@ ADC class com.microchip.mcc.mcu8.modules.adc.ADC + + ECCP1 + class com.microchip.mcc.mcu8.modules.eccp.ECCP + INTERNAL OSCILLATOR class com.microchip.mcc.mcu8.systemManager.osc_v3.Osc @@ -25,6 +29,10 @@ System Module class com.microchip.mcc.mcu8.systemManager.SystemManager + + TMR2 + class com.microchip.mcc.mcu8.modules.tmr2_v3.TMR2 + WDT class com.microchip.mcc.mcu8.systemManager.wdt.WDT @@ -336,7 +344,7 @@ - 0 + 128 @@ -380,7 +388,7 @@ - left + right @@ -406,6 +414,342 @@ 0 + + + ISR + + + + low + + + + low + + + + disabled + + + + 511 + + + + 25000000 + + + + 50.0 + + + + Enhanced PWM + + + + Timer2 + + + + enabled + + + + disabled + + + + periodMode + + + + 0.0 + + + + 24414.063 + + + + 4.096E-5 + + + + 10 + + + + P1A,P1C: active high; P1B,P1D: active high + + + + disabled + + + + enabled + + + + enabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + disabled + + + + timerselabsent + + + + true + + + + 1 + + + + 3 + + + + 2 + + + + 4 + + + + 5 + + + + 7 + + + + 6 + + + + 0 + + + + 0 + + + + 1 + + + + 0 + + + + 1 + + + + 2 + + + + 0 + + + + 1 + + + + 2 + + + + 7 + + + + 6 + + + + 11 + + + + 9 + + + + 4 + + + + 12 + + + + 13 + + + + 14 + + + + 15 + + + + 5 + + + + 8 + + + + 10 + + + + 2 + + + + 0 + + + + 1 + + + + 3 + + + + 2 + + + + 0 + + + + 1 + + + + 0 + + + + 0 + + + + 60 + + + + 0 + + + + 127 + + + + 128 + + + + disabled + + + + operating + + + + P1AP1C_0 + + + + P1BP1D_0 + + + + P1A,P1C: active high; P1B,P1D: active high + + + + 3 + + + + single + + + + disabled + + + + disabled + + + + -1 + + + + 1 + + + + 0 + + + + 127 + + + + 0 + + + + automatic_restart + @@ -3740,7 +4084,7 @@ - 255 + 251 @@ -4196,7 +4540,7 @@ - input + output @@ -4870,6 +5214,186 @@ OFF + + + 0 + + + + ISR + + + + 24414.0625 + + + + 25000000 + + + + periodMode + + + + 255 + + + + 0 + + + + 0.0000416 + + + + 0.00004096 + + + + 0.00004096 + + + + 0.00000016 + + + + enabled + + + + 0 + + + + 2 + + + + 1 + + + + 0 + + + + 1 + + + + 0 + + + + 9 + + + + 10 + + + + 11 + + + + 12 + + + + 13 + + + + 14 + + + + 15 + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 255 + + + + 4 + + + + 0 + + + + 255 + + + + 1:1 + + + + on + + + + 1:1 + + + + 0 + + + + disabled + + + + disabled + + + + -1 + + + + 1 + 131.07200 @@ -4878,16 +5402,12 @@ mcc_generated_files\mcc.h - 76efcdc733bc41365db52afc42f4dc2a4c5a5dec1c341d9bf59f709fe14ba352 + 163eeab73ba2645b62407134fd74f192252b4a78fc740ce8959eebb831a39c2e mcc_generated_files\device_config.h e658a4cb6ac1c79b2a52ab2754ebce26d229cbe4bd8464122f3272d1e76e5881 - - mcc_generated_files\adc.c - ea0ef3a92d13a952f6980f986f555d7c4bba4e5b900dad9d9109d77db50d08d2 - main.c 30e3e0e5956e494fcd566f1509f2f2bbc404d25265a77934114af7c9d1fcdbd7 @@ -4896,21 +5416,41 @@ mcc_generated_files\device_config.c 0c1446568049fa17e32a6aec2aad01e6cabc65cf60b9d57aceffd79e04f930c2 + + mcc_generated_files\tmr2.h + 9c49623fe191eb686818b525571464bbc0f83e271367728272f8bce53b917f55 + mcc_generated_files\pin_manager.h - 448e4663e5d24c453c5004d4a332ebc8bce89a0486f92a21c2d62d5019972c2c + a29093f3260f4f5a4c9bb40015c68aed2bf30664c16fade6df5035f8d97e736e + + + mcc_generated_files\tmr2.c + 05c23c08bae910023f51fd801fa4b4107358a34dbad1624e66d9a30249d1fe86 mcc_generated_files\adc.h 58eb4471903133ed806f7edbfce9c3cc4e0af3536917c8f81ad1cbdb72d919fc - mcc_generated_files\mcc.c - a08732cf19b1cf922560c2f4059da30321e0caa94c19d38cd6c26732222aeeb1 + mcc_generated_files\epwm1.h + e1dacec839b43c4ec99f1710c3a7872ce32d2ea6dfe3856eb466e690b7ea75c9 mcc_generated_files\pin_manager.c - 8c45d058158c57513c2f1af63d52c6bacb178924403b99a5e2bf1fca5a787c79 + f23627897b323c5e312c50538e92449a15673b1b943138129b8c0214ac47a4d4 + + + mcc_generated_files\epwm1.c + db307f67f622483528ffff92c5560b35b38162e4f93d1659723c7276b7265601 + + + mcc_generated_files\adc.c + 62188981f98a350cfcc3227def37b9ded03569aedb061a1566fc3d03028da8f1 + + + mcc_generated_files\mcc.c + eda682c043199d8627daf3584afc45a08bb3bb8526554f70c327ca6e3b587544 \ No newline at end of file