Tool/software:
HI Ti Team
I am trying to run ADC0 Channel 0 in interrupt mode. While the ADC interrupt is working, the callback function is not being invoked as expected.
Could you please review the code snippet below and let me know what might be missing?
Additionally, I have reviewed the MCU+ SDK 10.02 example adc_soc_continuous_dma
. I noticed that two callback functions are defined in the example, but neither of them appears to be triggered by any interrupt.
Looking forward to your guidance on this issue.
static void App_adcISR(void *args);
static void App_dmach0ISR(Edma_IntrHandle intrHandle, void *args);
these are the function of SDK example code
here is my code
Note- Code is working fine ADC conversion is proper as per input voltage.
#include <stdlib.h>
#include "ti_drivers_config.h"
#include "ti_board_config.h"
#include <kernel/dpl/ClockP.h>
#include <drivers/uart.h>
#include <drivers/adc.h>
#include <kernel/dpl/HwiP.h>
void hello_world_main(void *args);
void Uart_Inti();
HwiP_Params adc_params;
HwiP_Object my_adc;
#define CSLR_R5FSS0_CORE0_INTR_ADC0_INTR_0 (150U)
long unsigned int count = 0;
void adc_isr(void *arg) //this function is callback function for adc need to check is not calling
{
count++;
DebugP_log("call adc callback \r\n");
}
void adcOpen()
{
HwiP_Params_init(&adc_params);
adc_params.intNum = CSLR_R5FSS0_CORE0_INTR_ADC0_INTR_0;
adc_params.callback = &adc_isr;
adc_params.priority = 10;
ADC_setupSOC(CONFIG_ADC0_BASE_ADDR, 0, ADC_TRIGGER_SW_ONLY, ADC_CH_ADCIN0, 16);
ADC_enableConverter(CONFIG_ADC0_BASE_ADDR);
/* Delay for ADC to power up. */
ClockP_usleep(500);
ADC_enableInterrupt(CONFIG_ADC0_BASE_ADDR, 0);
// HwiP_Params_init(&adc_params);
HwiP_construct(&my_adc, &adc_params);
}
int main(void)
{
System_init();
Board_init();
hello_world_main(NULL);
DebugP_log("Start Initialize ADC0 \r\n");
adcOpen();
while(1)
{
ADC_clearInterruptStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1);
ADC_forceSOC(CONFIG_ADC0_BASE_ADDR, ADC_SOC_NUMBER0);
while(ADC_getInterruptStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1) == false)
{
}
DebugP_log("CH0 : %d\r\n", ADC_readResult(CONFIG_ADC0_RESULT_BASE_ADDR, ADC_SOC_NUMBER0));
DebugP_log("%d: ",count);
GPIO_pinWriteHigh(LED_RED_BASE_ADDR, LED_RED_PIN);
ClockP_sleep(1);
GPIO_pinWriteLow(LED_RED_BASE_ADDR, LED_RED_PIN);
ClockP_sleep(1);
// count=0;
}
Board_deinit();
System_deinit();
return 0;
}