From 87aa31868aa977c63b9955b54997d20c28a76ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Fri, 3 Mar 2023 16:11:29 +0100 Subject: [PATCH] - --- solar_panel.X/mcc_generated_files/eusart1.c | 18 +- solar_panel.X/mcc_generated_files/eusart1.h | 3 +- .../mcc_generated_files/pin_manager.c | 2 +- .../mcc_generated_files/pin_manager.h | 8 + solar_panel.X/mcc_generated_files/tmr0.c | 12 +- solar_panel.X/modbus.c | 10 +- solar_panel.X/nbproject/Makefile-default.mk | 154 ++++++++++-------- .../nbproject/Makefile-genesis.properties | 4 +- solar_panel.X/nbproject/configurations.xml | 2 + solar_panel.X/nbproject/private/private.xml | 10 +- solar_panel.X/solar_panel.mc3 | 48 +++--- solar_panel.X/uart.c | 7 + solar_panel.X/uart.h | 18 ++ 13 files changed, 176 insertions(+), 120 deletions(-) create mode 100644 solar_panel.X/uart.c create mode 100644 solar_panel.X/uart.h diff --git a/solar_panel.X/mcc_generated_files/eusart1.c b/solar_panel.X/mcc_generated_files/eusart1.c index 01e4133..5700d00 100644 --- a/solar_panel.X/mcc_generated_files/eusart1.c +++ b/solar_panel.X/mcc_generated_files/eusart1.c @@ -70,6 +70,8 @@ volatile eusart1_status_t eusart1RxLastError; /** Section: EUSART1 APIs */ +void (*EUSART1_RxDefaultInterruptHandler)(void); + void (*EUSART1_FramingErrorHandler)(void); void (*EUSART1_OverrunErrorHandler)(void); void (*EUSART1_ErrorHandler)(void); @@ -91,8 +93,8 @@ void EUSART1_Initialize(void) // SPEN enabled; RX9 9-bit; CREN enabled; ADDEN disabled; SREN disabled; RCSTA1 = 0xD0; - // TX9 9-bit; TX9D 0; SENDB sync_break_complete; TXEN enabled; SYNC synchronous; BRGH hi_speed; CSRC master_mode; - TXSTA1 = 0xF4; + // TX9 9-bit; TX9D 0; SENDB sync_break_complete; TXEN enabled; SYNC asynchronous; BRGH hi_speed; CSRC master_mode; + TXSTA1 = 0xE4; // SPBRG1 = 0x8A; @@ -138,12 +140,11 @@ eusart1_status_t EUSART1_get_last_status(void){ uint8_t EUSART1_Read(void) { uint8_t readValue = 0; - RCSTA1bits.SREN = 1; while(0 == eusart1RxCount) { } - + eusart1RxLastError = eusart1RxStatusBuffer[eusart1RxTail]; readValue = eusart1RxBuffer[eusart1RxTail++]; @@ -160,8 +161,6 @@ uint8_t EUSART1_Read(void) void EUSART1_Write(uint8_t txData) { - RCSTA1bits.SREN = 0; - RCSTA1bits.CREN = 0; while(0 == PIR1bits.TX1IF) { } @@ -169,6 +168,8 @@ void EUSART1_Write(uint8_t txData) TXREG1 = txData; // Write the data byte to the USART. } + + void EUSART1_Receive_ISR(void) { @@ -178,7 +179,7 @@ void EUSART1_Receive_ISR(void) eusart1RxStatusBuffer[eusart1RxHead].ferr = 1; EUSART1_FramingErrorHandler(); } - + if(RCSTA1bits.OERR){ eusart1RxStatusBuffer[eusart1RxHead].oerr = 1; EUSART1_OverrunErrorHandler(); @@ -190,7 +191,7 @@ void EUSART1_Receive_ISR(void) EUSART1_RxDataHandler(); } - // or set custom function using eusart1_SetRxInterruptHandler() + // or set custom function using EUSART1_SetRxInterruptHandler() } void EUSART1_RxDataHandler(void){ @@ -201,7 +202,6 @@ void EUSART1_RxDataHandler(void){ eusart1RxHead = 0; } eusart1RxCount++; - } void EUSART1_DefaultFramingErrorHandler(void){} diff --git a/solar_panel.X/mcc_generated_files/eusart1.h b/solar_panel.X/mcc_generated_files/eusart1.h index 79b6300..2a70662 100644 --- a/solar_panel.X/mcc_generated_files/eusart1.h +++ b/solar_panel.X/mcc_generated_files/eusart1.h @@ -91,8 +91,7 @@ extern volatile uint8_t eusart1RxCount; /** Section: EUSART1 APIs */ - -void (*EUSART1_RxDefaultInterruptHandler)(void); +extern void (*EUSART1_RxDefaultInterruptHandler)(void); /** @Summary diff --git a/solar_panel.X/mcc_generated_files/pin_manager.c b/solar_panel.X/mcc_generated_files/pin_manager.c index 0d327cb..4363a88 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 = 0xFB; + TRISC = 0xBB; 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 47c5454..16dddbc 100644 --- a/solar_panel.X/mcc_generated_files/pin_manager.h +++ b/solar_panel.X/mcc_generated_files/pin_manager.h @@ -75,6 +75,14 @@ #define RC2_SetDigitalInput() do { TRISCbits.TRISC2 = 1; } while(0) #define RC2_SetDigitalOutput() do { TRISCbits.TRISC2 = 0; } while(0) +// get/set RC6 procedures +#define RC6_SetHigh() do { LATCbits.LATC6 = 1; } while(0) +#define RC6_SetLow() do { LATCbits.LATC6 = 0; } while(0) +#define RC6_Toggle() do { LATCbits.LATC6 = ~LATCbits.LATC6; } while(0) +#define RC6_GetValue() PORTCbits.RC6 +#define RC6_SetDigitalInput() do { TRISCbits.TRISC6 = 1; } while(0) +#define RC6_SetDigitalOutput() do { TRISCbits.TRISC6 = 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/tmr0.c b/solar_panel.X/mcc_generated_files/tmr0.c index ad3ca68..d2d9627 100644 --- a/solar_panel.X/mcc_generated_files/tmr0.c +++ b/solar_panel.X/mcc_generated_files/tmr0.c @@ -71,11 +71,11 @@ void TMR0_Initialize(void) //Enable 16bit timer mode before assigning value to TMR0H T0CONbits.T08BIT = 0; - // TMR0H 255; - TMR0H = 0xFF; + // TMR0H 158; + TMR0H = 0x9E; - // TMR0L 252; - TMR0L = 0xFC; + // TMR0L 87; + TMR0L = 0x57; // Load TMR0 value to the 16-bit reload variable @@ -90,8 +90,8 @@ void TMR0_Initialize(void) // Set Default Interrupt Handler TMR0_SetInterruptHandler(TMR0_DefaultInterruptHandler); - // T0PS 1:2; T08BIT 16-bit; T0SE Increment_hi_lo; T0CS T0CKI; TMR0ON enabled; PSA not_assigned; - T0CON = 0xB8; + // T0PS 1:2; T08BIT 16-bit; T0SE Increment_hi_lo; T0CS FOSC/4; TMR0ON enabled; PSA not_assigned; + T0CON = 0x98; } void TMR0_StartTimer(void) diff --git a/solar_panel.X/modbus.c b/solar_panel.X/modbus.c index 604747c..c6c8523 100644 --- a/solar_panel.X/modbus.c +++ b/solar_panel.X/modbus.c @@ -1,6 +1,6 @@ #include "modbus.h" #include "crc.h" -//#include "uart.h" +#include "uart.h" #include #include #include @@ -37,9 +37,11 @@ void modbus_timer(void) } -uint8_t modbus_analyse_and_answer(void) -{ +uint8_t modbus_analyse_and_answer(void) { // TODO -> complete the modbus analyse and answer + rx_buf[0] = 0; + + //sprintf(tx_buf, "%i", modbusAddress, ); } @@ -63,5 +65,5 @@ void modbus_send(uint8_t length) void modbus_init(uint8_t address) { modbusAddress = address; - // TODO -> configute timer for modbus usage + // TODO -> confikre timer for modbus usage } \ No newline at end of file diff --git a/solar_panel.X/nbproject/Makefile-default.mk b/solar_panel.X/nbproject/Makefile-default.mk index 3315f44..b0689c8 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 mcc_generated_files/epwm1.c mcc_generated_files/tmr2.c mcc_generated_files/eusart1.c mcc_generated_files/interrupt_manager.c mcc_generated_files/tmr0.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 mcc_generated_files/epwm1.c mcc_generated_files/tmr2.c mcc_generated_files/eusart1.c mcc_generated_files/interrupt_manager.c mcc_generated_files/tmr0.c main.c crc.c measure.c modbus.c uart.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 ${OBJECTDIR}/mcc_generated_files/epwm1.p1 ${OBJECTDIR}/mcc_generated_files/tmr2.p1 ${OBJECTDIR}/mcc_generated_files/eusart1.p1 ${OBJECTDIR}/mcc_generated_files/interrupt_manager.p1 ${OBJECTDIR}/mcc_generated_files/tmr0.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 ${OBJECTDIR}/mcc_generated_files/eusart1.p1.d ${OBJECTDIR}/mcc_generated_files/interrupt_manager.p1.d ${OBJECTDIR}/mcc_generated_files/tmr0.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}/mcc_generated_files/epwm1.p1 ${OBJECTDIR}/mcc_generated_files/tmr2.p1 ${OBJECTDIR}/mcc_generated_files/eusart1.p1 ${OBJECTDIR}/mcc_generated_files/interrupt_manager.p1 ${OBJECTDIR}/mcc_generated_files/tmr0.p1 ${OBJECTDIR}/main.p1 ${OBJECTDIR}/crc.p1 ${OBJECTDIR}/measure.p1 ${OBJECTDIR}/modbus.p1 ${OBJECTDIR}/uart.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}/mcc_generated_files/epwm1.p1.d ${OBJECTDIR}/mcc_generated_files/tmr2.p1.d ${OBJECTDIR}/mcc_generated_files/eusart1.p1.d ${OBJECTDIR}/mcc_generated_files/interrupt_manager.p1.d ${OBJECTDIR}/mcc_generated_files/tmr0.p1.d ${OBJECTDIR}/main.p1.d ${OBJECTDIR}/crc.p1.d ${OBJECTDIR}/measure.p1.d ${OBJECTDIR}/modbus.p1.d ${OBJECTDIR}/uart.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 ${OBJECTDIR}/mcc_generated_files/epwm1.p1 ${OBJECTDIR}/mcc_generated_files/tmr2.p1 ${OBJECTDIR}/mcc_generated_files/eusart1.p1 ${OBJECTDIR}/mcc_generated_files/interrupt_manager.p1 ${OBJECTDIR}/mcc_generated_files/tmr0.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}/mcc_generated_files/epwm1.p1 ${OBJECTDIR}/mcc_generated_files/tmr2.p1 ${OBJECTDIR}/mcc_generated_files/eusart1.p1 ${OBJECTDIR}/mcc_generated_files/interrupt_manager.p1 ${OBJECTDIR}/mcc_generated_files/tmr0.p1 ${OBJECTDIR}/main.p1 ${OBJECTDIR}/crc.p1 ${OBJECTDIR}/measure.p1 ${OBJECTDIR}/modbus.p1 ${OBJECTDIR}/uart.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 mcc_generated_files/epwm1.c mcc_generated_files/tmr2.c mcc_generated_files/eusart1.c mcc_generated_files/interrupt_manager.c mcc_generated_files/tmr0.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 mcc_generated_files/epwm1.c mcc_generated_files/tmr2.c mcc_generated_files/eusart1.c mcc_generated_files/interrupt_manager.c mcc_generated_files/tmr0.c main.c crc.c measure.c modbus.c uart.c @@ -134,38 +134,6 @@ ${OBJECTDIR}/mcc_generated_files/adc.p1: mcc_generated_files/adc.c nbproject/Ma @-${MV} ${OBJECTDIR}/mcc_generated_files/adc.d ${OBJECTDIR}/mcc_generated_files/adc.p1.d @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/adc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ -${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/main.p1.d - @${RM} ${OBJECTDIR}/main.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}/main.p1 main.c - @-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d - @${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ - -${OBJECTDIR}/crc.p1: crc.c nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/crc.p1.d - @${RM} ${OBJECTDIR}/crc.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}/crc.p1 crc.c - @-${MV} ${OBJECTDIR}/crc.d ${OBJECTDIR}/crc.p1.d - @${FIXDEPS} ${OBJECTDIR}/crc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ - -${OBJECTDIR}/measure.p1: measure.c nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/measure.p1.d - @${RM} ${OBJECTDIR}/measure.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}/measure.p1 measure.c - @-${MV} ${OBJECTDIR}/measure.d ${OBJECTDIR}/measure.p1.d - @${FIXDEPS} ${OBJECTDIR}/measure.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ - -${OBJECTDIR}/modbus.p1: modbus.c nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/modbus.p1.d - @${RM} ${OBJECTDIR}/modbus.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}/modbus.p1 modbus.c - @-${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 @@ -206,6 +174,46 @@ ${OBJECTDIR}/mcc_generated_files/tmr0.p1: mcc_generated_files/tmr0.c nbproject/ @-${MV} ${OBJECTDIR}/mcc_generated_files/tmr0.d ${OBJECTDIR}/mcc_generated_files/tmr0.p1.d @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/tmr0.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ +${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/main.p1.d + @${RM} ${OBJECTDIR}/main.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}/main.p1 main.c + @-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d + @${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/crc.p1: crc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/crc.p1.d + @${RM} ${OBJECTDIR}/crc.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}/crc.p1 crc.c + @-${MV} ${OBJECTDIR}/crc.d ${OBJECTDIR}/crc.p1.d + @${FIXDEPS} ${OBJECTDIR}/crc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/measure.p1: measure.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/measure.p1.d + @${RM} ${OBJECTDIR}/measure.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}/measure.p1 measure.c + @-${MV} ${OBJECTDIR}/measure.d ${OBJECTDIR}/measure.p1.d + @${FIXDEPS} ${OBJECTDIR}/measure.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/modbus.p1: modbus.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/modbus.p1.d + @${RM} ${OBJECTDIR}/modbus.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}/modbus.p1 modbus.c + @-${MV} ${OBJECTDIR}/modbus.d ${OBJECTDIR}/modbus.p1.d + @${FIXDEPS} ${OBJECTDIR}/modbus.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/uart.p1: uart.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/uart.p1.d + @${RM} ${OBJECTDIR}/uart.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}/uart.p1 uart.c + @-${MV} ${OBJECTDIR}/uart.d ${OBJECTDIR}/uart.p1.d + @${FIXDEPS} ${OBJECTDIR}/uart.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + else ${OBJECTDIR}/lcd/lcd.p1: lcd/lcd.c nbproject/Makefile-${CND_CONF}.mk @${MKDIR} "${OBJECTDIR}/lcd" @@ -247,38 +255,6 @@ ${OBJECTDIR}/mcc_generated_files/adc.p1: mcc_generated_files/adc.c nbproject/Ma @-${MV} ${OBJECTDIR}/mcc_generated_files/adc.d ${OBJECTDIR}/mcc_generated_files/adc.p1.d @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/adc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ -${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/main.p1.d - @${RM} ${OBJECTDIR}/main.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}/main.p1 main.c - @-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d - @${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ - -${OBJECTDIR}/crc.p1: crc.c nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/crc.p1.d - @${RM} ${OBJECTDIR}/crc.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}/crc.p1 crc.c - @-${MV} ${OBJECTDIR}/crc.d ${OBJECTDIR}/crc.p1.d - @${FIXDEPS} ${OBJECTDIR}/crc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ - -${OBJECTDIR}/measure.p1: measure.c nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/measure.p1.d - @${RM} ${OBJECTDIR}/measure.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}/measure.p1 measure.c - @-${MV} ${OBJECTDIR}/measure.d ${OBJECTDIR}/measure.p1.d - @${FIXDEPS} ${OBJECTDIR}/measure.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ - -${OBJECTDIR}/modbus.p1: modbus.c nbproject/Makefile-${CND_CONF}.mk - @${MKDIR} "${OBJECTDIR}" - @${RM} ${OBJECTDIR}/modbus.p1.d - @${RM} ${OBJECTDIR}/modbus.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}/modbus.p1 modbus.c - @-${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 @@ -319,6 +295,46 @@ ${OBJECTDIR}/mcc_generated_files/tmr0.p1: mcc_generated_files/tmr0.c nbproject/ @-${MV} ${OBJECTDIR}/mcc_generated_files/tmr0.d ${OBJECTDIR}/mcc_generated_files/tmr0.p1.d @${FIXDEPS} ${OBJECTDIR}/mcc_generated_files/tmr0.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ +${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/main.p1.d + @${RM} ${OBJECTDIR}/main.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}/main.p1 main.c + @-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d + @${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/crc.p1: crc.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/crc.p1.d + @${RM} ${OBJECTDIR}/crc.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}/crc.p1 crc.c + @-${MV} ${OBJECTDIR}/crc.d ${OBJECTDIR}/crc.p1.d + @${FIXDEPS} ${OBJECTDIR}/crc.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/measure.p1: measure.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/measure.p1.d + @${RM} ${OBJECTDIR}/measure.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}/measure.p1 measure.c + @-${MV} ${OBJECTDIR}/measure.d ${OBJECTDIR}/measure.p1.d + @${FIXDEPS} ${OBJECTDIR}/measure.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/modbus.p1: modbus.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/modbus.p1.d + @${RM} ${OBJECTDIR}/modbus.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}/modbus.p1 modbus.c + @-${MV} ${OBJECTDIR}/modbus.d ${OBJECTDIR}/modbus.p1.d + @${FIXDEPS} ${OBJECTDIR}/modbus.p1.d $(SILENT) -rsi ${MP_CC_DIR}../ + +${OBJECTDIR}/uart.p1: uart.c nbproject/Makefile-${CND_CONF}.mk + @${MKDIR} "${OBJECTDIR}" + @${RM} ${OBJECTDIR}/uart.p1.d + @${RM} ${OBJECTDIR}/uart.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}/uart.p1 uart.c + @-${MV} ${OBJECTDIR}/uart.d ${OBJECTDIR}/uart.p1.d + @${FIXDEPS} ${OBJECTDIR}/uart.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 da78265..7884d01 100644 --- a/solar_panel.X/nbproject/Makefile-genesis.properties +++ b/solar_panel.X/nbproject/Makefile-genesis.properties @@ -1,11 +1,11 @@ # -#Fri Mar 03 14:42:22 CET 2023 +#Fri Mar 03 16:00:47 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=19a2811a74f6d1b3cc6f3802bb8369cf +configurations-xml=5e78976b44c48e5125d650f70012f653 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 f432be8..f6809b7 100644 --- a/solar_panel.X/nbproject/configurations.xml +++ b/solar_panel.X/nbproject/configurations.xml @@ -23,6 +23,7 @@ crc.h measure.h modbus.h + uart.h crc.c measure.c modbus.c + uart.c + file:/C:/Users/remi/Downloads/MCU/solar_panel/solar_panel.X/modbus.c 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/modbus.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 + file:/C:/Program%20Files/Microchip/xc8/v2.40/pic/sources/c99/common/lwmod.c + file:/C:/Users/remi/Downloads/MCU/solar_panel/solar_panel.X/mcc_generated_files/interrupt_manager.c + file:/C:/Program%20Files/Microchip/xc8/v2.40/pic/sources/c99/common/aomod.c + file:/C:/Users/remi/Downloads/MCU/solar_panel/solar_panel.X/mcc_generated_files/tmr0.c + file:/C:/Users/remi/Downloads/MCU/solar_panel/solar_panel.X/mcc_generated_files/eusart1.c diff --git a/solar_panel.X/solar_panel.mc3 b/solar_panel.X/solar_panel.mc3 index c4cb3de..0787f8a 100644 --- a/solar_panel.X/solar_panel.mc3 +++ b/solar_panel.X/solar_panel.mc3 @@ -1004,7 +1004,7 @@ - 244 + 228 @@ -1112,7 +1112,7 @@ - synchronous + asynchronous @@ -4464,7 +4464,7 @@ - 251 + 187 @@ -4936,7 +4936,7 @@ - input + output @@ -5604,7 +5604,7 @@ - 0.00003 + 0.004 @@ -5616,11 +5616,11 @@ - 0.65535 + 0.0104856 - 0.00001 + 0.00000016 @@ -5632,15 +5632,15 @@ - 100000 + 6250000 - 0.000035 + 0.004 - enabled + disabled @@ -5724,15 +5724,15 @@ - 184 + 152 - 255 + 158 - 252 + 87 @@ -5752,7 +5752,7 @@ - T0CKI + FOSC/4 @@ -5760,11 +5760,11 @@ - 255 + 158 - 252 + 87 @@ -5982,7 +5982,7 @@ mcc_generated_files\eusart1.h - c6209c27bd9de6f3041c2f8d1df1cccce2b09bdf4b5098ae0b333a7f92205022 + cb7a354159e217ac3955f23cce6d01d65df54018be773e73654ec951df42a7e9 mcc_generated_files\tmr0.h @@ -6000,14 +6000,14 @@ mcc_generated_files\tmr2.h 9c49623fe191eb686818b525571464bbc0f83e271367728272f8bce53b917f55 - - mcc_generated_files\pin_manager.h - a29093f3260f4f5a4c9bb40015c68aed2bf30664c16fade6df5035f8d97e736e - mcc_generated_files\tmr2.c 05c23c08bae910023f51fd801fa4b4107358a34dbad1624e66d9a30249d1fe86 + + mcc_generated_files\pin_manager.h + 87e93cc6f9494828e660861178e9a299efbe16d73a441d92e3dca2a1cf6d54ed + mcc_generated_files\adc.h 58eb4471903133ed806f7edbfce9c3cc4e0af3536917c8f81ad1cbdb72d919fc @@ -6018,11 +6018,11 @@ mcc_generated_files\tmr0.c - 6ee4809b94f1e2488f05488f97e0cdc3e8db39b9f132a99c2d2daf3b13befbf7 + f8a9d57b93e4810bdf2401ef043ce48c9d645ba81f2241dee96977286f6fb164 mcc_generated_files\pin_manager.c - f23627897b323c5e312c50538e92449a15673b1b943138129b8c0214ac47a4d4 + 1f9236370706611180887eedcb54392c08476036ee99409ce0d9a1f39ef165fb mcc_generated_files\epwm1.c @@ -6042,7 +6042,7 @@ mcc_generated_files\eusart1.c - 627becf328c45a7c7ebff85e99496289e162e55eef7d703ea105fffd0439dd76 + d8ed730bd093892491a853d1821faa71f3a66365e71b5728f5d34612524be6ec \ No newline at end of file diff --git a/solar_panel.X/uart.c b/solar_panel.X/uart.c new file mode 100644 index 0000000..8d8717e --- /dev/null +++ b/solar_panel.X/uart.c @@ -0,0 +1,7 @@ +#include "uart.h" + +void uart_send(uint8_t *tx_buf, uint8_t length){ + for (uint8_t i = 0; i < length; i++){ + EUSART1_Write(tx_buf[i]); + } +} diff --git a/solar_panel.X/uart.h b/solar_panel.X/uart.h new file mode 100644 index 0000000..57db5f4 --- /dev/null +++ b/solar_panel.X/uart.h @@ -0,0 +1,18 @@ +/* + * File: uart.h + * Author: remi + * + * Created on March 3, 2023, 3:23 PM + */ + +#ifndef UART_H +#define UART_H + +#include "mcc_generated_files/mcc.h" + +void uart_send(uint8_t *tx_buf, uint8_t length); + + + +#endif /* UART_H */ +