优化ADC
This commit is contained in:
parent
f01da795ed
commit
abc5ced7cb
|
@ -363,7 +363,7 @@ int main(void)
|
||||||
valve_switch_freq = valve_switch_on_freq;
|
valve_switch_freq = valve_switch_on_freq;
|
||||||
VavleDect_Switch();
|
VavleDect_Switch();
|
||||||
#endif
|
#endif
|
||||||
BSP_VAVLE_Init();
|
// BSP_VAVLE_Init();
|
||||||
|
|
||||||
ShowLed();
|
ShowLed();
|
||||||
BEEP_ON;
|
BEEP_ON;
|
||||||
|
|
|
@ -32,9 +32,9 @@ uint8_t BSP_ReadVbat(void)
|
||||||
// VBAT
|
// VBAT
|
||||||
uint32_t CountBat = 0;
|
uint32_t CountBat = 0;
|
||||||
ADC_InterBATSampInit();
|
ADC_InterBATSampInit();
|
||||||
DelayUs(1);
|
DelayUs(50);
|
||||||
ADC_ExcutSingleConver();
|
ADC_ExcutSingleConver();
|
||||||
DelayUs(1);
|
DelayUs(50);
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
adcBuff[i] = ADC_ExcutSingleConver(); // 连续采样20次
|
adcBuff[i] = ADC_ExcutSingleConver(); // 连续采样20次
|
||||||
|
@ -55,7 +55,7 @@ uint8_t BSP_ReadVbat(void)
|
||||||
// PGA=-12db
|
// PGA=-12db
|
||||||
// CountBat = CountBat * 1050 / 512 - (3 * 1050);
|
// CountBat = CountBat * 1050 / 512 - (3 * 1050);
|
||||||
CountBat = CountBat * 2.05078125 - 3150;
|
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);
|
logDebug("AverageCountBat = %dmV, vbat = %d(100mV)", CountBat, vbat);
|
||||||
|
|
||||||
//缩小到100mV
|
//缩小到100mV
|
||||||
|
|
|
@ -286,7 +286,7 @@ void KEY_ProcessLoop(void)
|
||||||
if (key_wakeup_flag)
|
if (key_wakeup_flag)
|
||||||
{
|
{
|
||||||
// 阻止睡眠
|
// 阻止睡眠
|
||||||
BSP_BlockSleep();
|
// BSP_BlockSleep();
|
||||||
// BSP_RequestBoost();
|
// BSP_RequestBoost();
|
||||||
|
|
||||||
// 关按键中断
|
// 关按键中断
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* Description : source file(ch585/ch584)
|
* Description : source file(ch585/ch584)
|
||||||
*********************************************************************************
|
*********************************************************************************
|
||||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
* 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.
|
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
@ -462,6 +462,17 @@ __HIGH_CODE
|
||||||
__attribute__((weak))
|
__attribute__((weak))
|
||||||
void HardFault_Handler(void)
|
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();
|
FLASH_ROM_SW_RESET();
|
||||||
sys_safe_access_enable();
|
sys_safe_access_enable();
|
||||||
R16_INT32K_TUNE = 0xFFFF;
|
R16_INT32K_TUNE = 0xFFFF;
|
||||||
|
@ -565,7 +576,7 @@ int _write(int fd, char *buf, int size)
|
||||||
#elif DEBUG == Debug_UART2
|
#elif DEBUG == Debug_UART2
|
||||||
while(R8_UART2_TFC == UART_FIFO_SIZE); /* 等待数据发送 */
|
while(R8_UART2_TFC == UART_FIFO_SIZE); /* 等待数据发送 */
|
||||||
R8_UART2_THR = *buf++; /* 发送数据 */
|
R8_UART2_THR = *buf++; /* 发送数据 */
|
||||||
#elif DEBUG == Debug_UART3
|
#elif DEBUG == Debug_UART3
|
||||||
while(R8_UART3_TFC == UART_FIFO_SIZE); /* 等待数据发送 */
|
while(R8_UART3_TFC == UART_FIFO_SIZE); /* 等待数据发送 */
|
||||||
R8_UART3_THR = *buf++; /* 发送数据 */
|
R8_UART3_THR = *buf++; /* 发送数据 */
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue