2026-02-24 10:43 PM
Hello Max VIZZINI ,
I'm using SPC58EC80E5 evaluation kit in that im working on SARADC , PB[1] i'm taking as ADC pin and connected 10k potentiometer to it.im getting continous 8192 adc value even after rotating the potentiometer , im using 12 bit ADC and checking the ADC values in CAN bus, i shared related configuration check it and please help me to solve this issue.
#include "components.h"
#include "saradc_lld.h"
#include "saradc_lld_cfg.h"
#include "can_lld.h"
#include "can_lld_cfg.h"
#include "osal.h"
#define ADC_CHANNEL 66U
static uint16_t adc_value;
CANTxFrame txmsg;
int main(void)
{
componentsInit();
/* Start ADC */
saradc_lld_start(&SARADC12D1, &saradc_config_saradcconf);
/* Start CAN */
can_lld_start(&CAND2, &can_config_mcanconf);
/* CAN frame setup */
txmsg.IDE = CAN_ID_STD;
txmsg.SID = 0x123;
txmsg.RTR = 0;
txmsg.DLC = 2;
while (1)
{
/* Start ADC conversion */
saradc_lld_start_conversion(&SARADC12D1);
/* Wait for conversion */
while (SARADC12D1.saradc->ICDR[ADC_CHANNEL].B.VALID == 0U)
{
}
/* Read ADC value */
adc_value = saradc_lld_readchannel(&SARADC12D1, ADC_CHANNEL);
// if (adc_value == SARADC_INVALID_DATA)
// {
// continue;
// }
/* Send ADC value over CAN */
txmsg.data8[0] = (adc_value >> 8) & 0xFF;
txmsg.data8[1] = adc_value & 0xFF;
can_lld_transmit(&CAND2, 0, &txmsg);
osalThreadDelayMilliseconds(100);
}
}
CAN is working properly , im transmiting data in while(1) infinet loop but im receiving only 4 times 8192 in the CAN.
2026-04-15 12:57 AM
Hi Pooja,
Let me guide you through the implementation of an ADC demo application:
Now click on "SARADC" in the Outline window
If you have difficulties implementing from scratch a working ADC application, you may import one of the prebuild AutoDevKit projects.
Considering you are using a board embedded with a SPC58EC80E, the best demo candidate is:
"SPC58ECxx_RLA SARADC Test Application for DiscoveryPlus"
BR
Simone
AEK_Team