RL78 -[10]- CS+_CACX_Lab4_ADC_內部參考電壓

RL78內部有一LDO可以產生1.45v的內部參考電壓

可以幫助使用者在做外部電壓量測前先做參考電壓校正


002


1. Code Generator (Design Tool)

A/D Converter > A/D convertor operation setting : Used

Resolution setting : 10 bits

A/D channel selection : Internal reference voltage output

003


2. Procedure Modify

在main.c加入全域變數

1
2
uint16_t adcValue[1];
double refVol;// adc refer voltage


main()

啟動ADC function

1
2
    R_ADC_Set_OperationOn();
    R_ADC_Start();

004


r_cg_adc_user.c

1
#include <math.h>



1.45v = ReferVoltage * ( ADC_value / 2^10 )

ReferVoltage = ( 1.45v * 2^10 ) / ADC_value

1
2
3
4
5
6
7
8
    extern uint16_t adcValue[1];
    extern double refVol;
    double ref145;
    
    ref145 = pow(2,10) * 1.45;// 2^7 * 1.45
    
    R_ADC_Get_Result(adcValue);
    refVol = ref145 / (double)adcValue[0];

001


3. Build & Download

002

留言