2025-03-05 1:08 AM - edited 2025-03-05 1:09 AM
Hello
I intend to use SARADC with SPC570S-DISP chip and I'm not able to operate correctly.
I configured the saradc driver to use the pin ANP8, which corresponds to the board's potentiometer. I set up an interrupt to read the value. While the counter inside the interrupt is functioning, the ADC value does not change when I adjust the potentiometer.
The main.c is attached to this post :
#include "components.h"
#include "saradc_lld_cfg.h"
#include "osal.h"
/*
* Application entry point.
*/
static vuint16_t value;
static vuint8_t isDataReady;
static vuint16_t counter;
void saradcconf_adc_isr(SARADCDriver *saradcp){
value = saradc_lld_readchannel(saradcp, PIN_ANP8);
isDataReady = TRUE;
counter++;
}
int main(void) {
counter=0;
value = 0;
isDataReady = FALSE;
/* Initialization of all the imported components in the order specified in
the application wizard. The function is generated automatically.*/
componentsInit();
/* Uncomment the below routine to Enable Interrupts. */
irqIsrEnable();
// Enable SARADC
// saradc_lld_start_conversion(&SARADC12D1);
saradc_lld_start(&SARADC12DSV, &saradc_config_saradcconf);
saradc_lld_start_conversion(&SARADC12DSV);
/* Application main loop.*/
for ( ; ; ) {
if(isDataReady == TRUE){
isDataReady = FALSE;
// saradc_lld_start(&SARADC12DSV, &saradc_config_saradcconf);
saradc_lld_start_conversion(&SARADC12DSV);
}
osalThreadDelayMilliseconds(1000);
}
}
Does someone know if there is an error or a problem in the configuration ?
Thank you !