Follow+Star Public Account Number, don’t miss the wonderful content
Arrangement | strongerHuang
Source | CW32 Ecological Community
Main Functions
Circuit Design
Design Concept:
Software Code and Debugging
1. GUI — LCD Driver and UI
2. FreeRTOS — RTOS System
3. USER — Low-level Drivers and App
uint16_t get_bat_val(void){ uint32_t sum = 0; uint16_t bat_val; uint32_t len = sizeof(BAT_ADC_ResultBuff) / 2; uint16_t max = 0; uint16_t min = 0xffff; int i; for ( i = 0; i < len; i++) { sum += BAT_ADC_ResultBuff[i]; if(BAT_ADC_ResultBuff[i] > max) { max = BAT_ADC_ResultBuff[i]; } if(BAT_ADC_ResultBuff[i] < min) { min = BAT_ADC_ResultBuff[i]; } } sum -= max + min; sum = sum / (len - 2); sum = dynamic_mean(bat_cahe,sum,len_cahe); // sum -= 30; bat_val = sum * 2500 * 2 /4095; return bat_val;}
void GTIM1_IRQHandler(void) { static uint16_t TimeCnt = 0; GTIM_ClearITPendingBit(CW_GTIM1, GTIM_IT_OV); if (TimeCnt++ >= 100) { TimeCnt = 0; GTIM_SetCompare1(CW_GTIM1, PosWidth); } /* USER CODE END */ }
Leave a Comment
Your email address will not be published. Required fields are marked *