Hello,
I'm tryng to use a board mounting a RISC-V ch32v307 in developement ambient MounRiver Community.
You can find examples in https://github.com/openwch/ch32v307 and microcontroller RM in https://www.wch-ic.com/downloads/CH32FV2x_V3xRM_PDF.html
Many thank for 120 project examples , but I prefer a GOOD reference manual.
The example I try ,in EVT\EXAM\ADC\Internal_Temperature, use the internal temperature sensor I THINK WITH CALIBRATION.
In fact the system call a Get_CalibrationValue().
Has somebody an Idea what the fonction is doing? there is a reference manual where understand this code?
*********************************************************************
* @fn Get_CalibrationValue
*
* @brief Get ADCx Calibration Value.
*
* @param ADCx - where x can be 1 or 2 to select the ADC peripheral.
*
* @return CalibrationValue
*/
int16_t Get_CalibrationValue(ADC_TypeDef *ADCx)
{
__IO uint8_t i, j;
uint16_t buf[10];
__IO uint16_t t;
for(i = 0; i < 10; i++)
{
ADC_ResetCalibration(ADCx);
while(ADC_GetResetCalibrationStatus(ADCx))
;
ADC_StartCalibration(ADCx);
while(ADC_GetCalibrationStatus(ADCx))
;
buf[i] = ADCx->RDATAR;
}
for(i = 0; i < 10; i++)
{
for(j = 0; j < 9; j++)
{
if(buf[j] > buf[j + 1])
{
t = buf[j];
buf[j] = buf[j + 1];
buf[j + 1] = t;
}
}
}
t = 0;
for(i = 0; i < 6; i++)
{
t += buf[i + 2];
}
t = (t / 6) + ((t % 6) / 3);
return (int16_t)(2048 - (int16_t)t);
}