R5F10DPJLFB ADC Driver Sample code

Hello Sir,

I already have driver written, but the raw ADC count is differ in between 10-20 count.

So might be we are missing something in the logic.

If we have sample driver code,

FYI:

We are using below configuration for ADC

- Single Shot

- Software trigger

Thanks,

Nitin

  • Hello dear Nitin.
    Probably your code is working properly as you're observing a 2% drift in your data, and your problem is related to your specific hardware. some reasons affect ADC conversion value:

    -You might have connected a noisy power supply to your board, and there's a ripple in your VCC, AVCC, or ADC Vref pins. (Try using decoupling capacitors and make proper filters, try using a battery as the power source and make sure your circuit is compliant with analog hardware design guides)

    -The impedance of the analog input signal: Make sure the voltage that you're measuring by ADC is stable and isn't a high-impedance voltage source. 

    After all, if you believe hardware isn't the case, try the below sample codes, or even try software average filters in your code. 


    Please check out this link for ADC sample codes, ADC peripherals in the RL78 device are almost identical, so you can use them with a slight change for the D1A series. 

    I hope you find this helpful. don't hesitate to ask further questions if needed. 

    Best regards. Hossein

    If this or any other user's response answers your concern, kindly verify the answer. Thank you!

    Renesas Engineering Community Moderator
    https://community.renesas.com/
    https://academy.renesas.com/
    en-support.renesas.com/.../

  • You will always have a smaller or bigger fluctuation, first and foremost due to thermal noise which exists always.

    You may also have other sources of noise as Hossein mentioned, and as a result there will be an overall error of the ADC.

    On your device the overall error is ensured to be < 3.5 LSB and has a typical value of 1.2 LSB.

    Also, please make sure you do not have any floating analog input as they can induce noise in an adjacent analog input. Please follow section 2.3 section on how to handle unused pins.

    www.renesas.com/.../rl78d1a-users-manual-hardware-rev110

  • Hi,

    I can see P23 pin is floating, so if I set this pin to High by software, then does this will work?.

    if you have instruction to set this pin to High then please provide me.

    Thanks,

    Nitin 

  • What pin is P23 ? If it is unused, then follow the instructions on section 2.3.

    Is it the analog pin you are reading ?

  • Currently this pin is not connected to anything. That is just unused.

    The Pin 23 is Analog pin

    As per section 2.3 it is requesting to short with VSS or VDD with external circuitry.

    But my question is, can we connect it to internal pull up register (by software) and does this will work ?

  • Please see section 2.3 for unused pins.

    An analog pin should not be left floating. The difference of your ADC result is more than reasonable if it is left floating. You should connect this pin somewhere (ground, VDD, input voltage)