cancel
Showing results for 
Search instead for 
Did you mean: 

How to use saradc with SPC570S

SasukE15
Associate

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.

SasukE15_0-1741165133376.png

SasukE15_1-1741165185000.png

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); } }
View more

 

Does someone know if there is an error or a problem in the configuration ?

Thank you !

1 REPLY 1
FSPIL
ST Employee

Hi  SasukE15,

are you using the SPC5 Studio? I believe you can find examples about how using the SARADC.

 


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.