Hello,
im using the NHS3152 and i have a problem so generate a interrupt with the adc when the conversion is done. When i use the adc with polling everything is fine and i can read the correct value from the adc. But when i switch to interrupt controlled method i dont get an interrupt here. I tried to debugg with breakpoints and variable changes but still no interrupt. I also checked the
ADC_INT_STATUS and NVIC_BASE to see which interrupts are enabled. So here i clearly can see that my config is fine. In ADC_INT_STATUS i can see the bit for the conversion is complete and the interrupt is set to 1. Also the bit (nr 26) in the NVIC Table is set to 1. Im stuckt to find the problem here. May i set additional setting ?
The IRQ is defined as weak so i easy can overwrite it with my own written one. correct my if im false.
#define BATTERY_ANALOG_PIN IOCON_ANA0_0
#define BATTERY_ANALOG_IO ADCDAC_IO_ANA0_0
#define NVIC_BASE 0xE000E100
#define ADC_INT_STATUS 0x4001C028
void initBatteryMeassurment()
{
Chip_ADCDAC_Init(NSS_ADCDAC0);
Chip_ADCDAC_SetMuxADC(NSS_ADCDAC0,BATTERY_ANALOG_IO);
Chip_ADCDAC_SetModeADC(NSS_ADCDAC0,ADCDAC_CONTINUOUS);
Chip_ADCDAC_Int_SetEnabledMask(NSS_ADCDAC0,ADCDAC_INT_ALL); //enable ADC interrupts
Chip_IOCON_SetPinConfig(NSS_IOCON,BATTERY_ANALOG_PIN,IOCON_FUNC_1);
NVIC_EnableIRQ(ADCDAC_IRQn); //enable ADC IRQ general
Chip_ADCDAC_StartADC(NSS_ADCDAC0);
}
int main(void)
{
Chip_Clock_Clkout_SetClockSource(CLOCK_CLKOUTSOURCE_SYSTEM);
Chip_RTC_Init(NSS_RTC);
Chip_EEPROM_Init(NSS_EEPROM);
Chip_IOCON_Init(NSS_IOCON);
Chip_GPIO_Init(NSS_GPIO);
int* volatile int_enable = (int*) NVIC_BASE;
int* volatile adc_int_status = (int*) ADC_INT_STATUS;
initBatteryMeassurment();
while(1);
return 0;
}
void ADC_IRQHandler(void)
{
adcValue = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);
voltage = (float) 1*adcValue/4096;
}
Hi,
Looks like you are checking ISER0 register and IMSC register instead, and from my understanding , such kind of checking method should be put right after the initial process, for example, initBatteryMeassurment() here. and from the UM10876, ADC interrupt is No.25 interrupt source, No.26 is for WDT.
so would you please have a double check? Thanks for your patience!
Have a great day,
Kan
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
You are right its not nr. 26 its nr. 25 but i use ADCDAC_IRQn in NVIC_EnableIRQ(ADCDAC_IRQn); and its defines as 25.
I also checked the status registers before and after the inital process. the register ISER0 which is the NVIC_BASE Addr and the MSI @ 0x4001 C030 instead where i can read the conversion has finished and interrupt is enabled. im with you that the IMSC is totaly wrong. i checked the MSI instead.
When im wrong with the ISER0, which register hold the bit for enable the ADC interrupt ? or is there an other routine to enable these interrupts ?
thanks and have a nice day
Joschka
Hi Joschka,
Actually I didn't find any obvious error from your code, I just tested your code based on the project of "app_demo_dp_blinky", and almost all of the codes are from yours , the change I made is adding Board_Init() in the beginning of main().
The application runs just as expected.See the breakpoint hit as shown below.
did you test the same? or did you use the demo board or custom board? Please kindly clarify.
Have a great day,
Kan
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Thats sounds like everything is fine....
Looks like there is a bug in debugging with a J-Flash and LPCXpresso IDE.
now i get the interrupt also without board_init() and it looks fine but its not. I come to the next problem. I have to restart everything to get the interrupts after termination of the debugging process.
After the restart the interrupt occurs once and doesnt occur afterwards.
void ADC_IRQHandler(void){
Chip_ADCDAC_Int_ClearRawStatus(NSS_ADCDAC0,ADCDAC_INT_ALL);
NVIC_ClearPendingIRQ(ADCDAC_IRQn);
adcValue = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);
voltage = (float) 1*adcValue/4096;
//Chip_ADCDAC_StartADC(NSS_ADCDAC0);
}
In the ISR i directly clear the IRQs to avoid problems there. I tried to use the adc with continuous and single mode but same behaviour.
Hi Joschka,
Actually clearing the IRQs is normal for interrupt services, I could not find any obvious wrong here.
Have a great day,
Kan
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------