diff --git a/APP/peripheral_main.c b/APP/peripheral_main.c index 51bf7ed..95ab06c 100644 --- a/APP/peripheral_main.c +++ b/APP/peripheral_main.c @@ -363,7 +363,7 @@ int main(void) valve_switch_freq = valve_switch_on_freq; VavleDect_Switch(); #endif - BSP_VAVLE_Init(); + // BSP_VAVLE_Init(); ShowLed(); BEEP_ON; diff --git a/BSP/src/bsp_adc.c b/BSP/src/bsp_adc.c index 9219443..42ba376 100644 --- a/BSP/src/bsp_adc.c +++ b/BSP/src/bsp_adc.c @@ -32,9 +32,9 @@ uint8_t BSP_ReadVbat(void) // VBAT uint32_t CountBat = 0; ADC_InterBATSampInit(); - DelayUs(1); + DelayUs(50); ADC_ExcutSingleConver(); - DelayUs(1); + DelayUs(50); for (i = 0; i < 20; i++) { adcBuff[i] = ADC_ExcutSingleConver(); // 连续采样20次 @@ -55,7 +55,7 @@ uint8_t BSP_ReadVbat(void) // PGA=-12db // CountBat = CountBat * 1050 / 512 - (3 * 1050); CountBat = CountBat * 2.05078125 - 3150; - uint8_t vbat = (uint8_t)(CountBat / 100); + uint8_t vbat = (uint8_t)((CountBat + 50) / 100); logDebug("AverageCountBat = %dmV, vbat = %d(100mV)", CountBat, vbat); //缩小到100mV diff --git a/BSP/src/bsp_key.c b/BSP/src/bsp_key.c index d31d96c..317029d 100644 --- a/BSP/src/bsp_key.c +++ b/BSP/src/bsp_key.c @@ -286,7 +286,7 @@ void KEY_ProcessLoop(void) if (key_wakeup_flag) { // 阻止睡眠 - BSP_BlockSleep(); + // BSP_BlockSleep(); // BSP_RequestBoost(); // 关按键中断 diff --git a/StdPeriphDriver/CH58x_sys.c b/StdPeriphDriver/CH58x_sys.c index 0c78b0d..c188141 100644 --- a/StdPeriphDriver/CH58x_sys.c +++ b/StdPeriphDriver/CH58x_sys.c @@ -6,7 +6,7 @@ * Description : source file(ch585/ch584) ********************************************************************************* * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd. - * Attention: This software (modified or not) and binary are used for + * Attention: This software (modified or not) and binary are used for * microcontroller manufactured by Nanjing Qinheng Microelectronics. *******************************************************************************/ @@ -462,6 +462,17 @@ __HIGH_CODE __attribute__((weak)) void HardFault_Handler(void) { + uint32_t v_mepc,v_mcause,v_mtval; + printf("hardfault\n"); + + v_mepc=__get_MEPC(); + v_mcause=__get_MCAUSE(); + v_mtval=__get_MTVAL(); + + printf("mepc:%08x\n",v_mepc); + printf("mcause:%08x\n",v_mcause); + printf("mtval:%08x\n",v_mtval); + FLASH_ROM_SW_RESET(); sys_safe_access_enable(); R16_INT32K_TUNE = 0xFFFF; @@ -565,7 +576,7 @@ int _write(int fd, char *buf, int size) #elif DEBUG == Debug_UART2 while(R8_UART2_TFC == UART_FIFO_SIZE); /* ȴݷ */ R8_UART2_THR = *buf++; /* */ -#elif DEBUG == Debug_UART3 +#elif DEBUG == Debug_UART3 while(R8_UART3_TFC == UART_FIFO_SIZE); /* ȴݷ */ R8_UART3_THR = *buf++; /* */ #endif