Help using ADC of the RSL10

Hi,
I’m trying to evaluate the ADC of the RSL10 using the DIO (0…4). below a sample of the code to configure the ADC (the same one as the one used in the ADC_UART but with DIO1).

/* Set the ADC configuration */

Sys_ADC_Set_Config(ADC_CONTINUOUS|ADC_PRESCALE_6400);

/* Enable the ADC and BATMON alarm interrupts assigning channel
* number 6 to trigger the ADC interrupt. */

Sys_ADC_Set_BATMONIntConfig(INT_EBL_ADC |ADC_INT_CH6 |INT_EBL_BATMON_ALARM);

/* Configure ADC_CHANNEL input selection to DIO */

Sys_ADC_InputSelectConfig(ADC_CHANNEL, ADC_POS_INPUT_DIO1|ADC_NEG_INPUT_GND);

/* Configure both input selection for an ADC channel to GND so the OFFSET is
 * subtracted automatically to result. */

Sys_ADC_InputSelectConfig(ADC_GND_CHANNEL, ADC_POS_INPUT_GND |
ADC_NEG_INPUT_GND);

/* Enable interrupts */

NVIC_EnableIRQ(ADC_BATMON_IRQn);

I have some question and remarks:

  1. I can get my converted value in the interruption respecting the Sampling rate configured of the ADC

  2. DIO1 used in my example should be configured as an input before configuring the ADC?
    Because when is not done, I have 2V converted by ADC when my source is not connected to this PIN

  3. I tried to disable the ADC interrupt and getting my converted data in the main loop by checking the status using : Sys_ADC_Get_BATMONStatus(). This status is always 0, that mean no New sample ready.

do you have any idea about the 2. and 3. points ?

Best regards,

@Embed
To use ADC functionality, the DIO must be configured as follows:

  1. Set the IO_MODE field of the DIO_CFG register to 0x3F.
  2. Set the PULL_CTRL field of the DIO_CFG register to 0x0.

image

Q3: I tried to disable the ADC interrupt and getting my converted data in the main loop by checking the status using : Sys_ADC_Get_BATMONStatus(). This status is always 0, that mean no New sample.

A3: it sounds like you would like to constantly check the ‘ Sys_ADC_Get_BATMONStatus() ’ to see if a new data point is ready in the ADC, instead of having the ADC trigger an Interrupt.

In this situation, the below structure would be considered when it is returned from the ‘ Sys_ADC_Get_BATMONStatus() ’ function, and as you can see, checking Bit 0 will essentially tell you if a new ADC sample is available.

image

For this one, treat the ‘ Sys_ADC_Get_BATMONStatus() ’ return value as a register bit array, and is looking at the proper location (ie. ‘’ Sys_ADC_Get_BATMONStatus() & 0x1 ’ to ensure we are only considering the first bit in the 32 bit array).

In this case value ADC_BATMON_STATUS is binary 0011 = Hexadecimal 0x3

Thank you for using our community forum!

Hi Martin,
Thank you for your answer but i don’t get the same result as you, impossible for me to have the status changed.
Could you test my enclosed sample code with your board and tell me if you get something different?

Best regards,

app.c (21,8 Ko)

@Embed

We have checked your code and can see the issue you are talking about.

We have looked at the document for LSDAD_BATMON_STATUS again.
It seems that we should enable LSAD_BATMON_INT_ENABLE first,
and then this LSAD_BATMON_STATUS status register can be used.

  1. By using this register, we could know which source has triggered the interrupt .
  2. When a new ready interrupt occurred, the LSAD_READY_STAT is asserted.
    so we should enable interrupt first and then this register can work for interrupt .

Note: This status register can also be used without using interrupts IRQ.
(But we still need enable interrupt first).

For practice,
By changing INT_DIS_ADC into INT_EBL_ADC, your code can stop at the breakpoint.

Thank you for using our community forum!

thank you for your response.

in the meantime I had done that and it worked.

Best regards,

1 Like

@Embed

Thank you for an update and using our community forum!