#define CLKDIV 119 /** * @brief peripheral configuration */ typedef enum {PERIPH_DISABLE = 0, PERIPH_ENABLE = !PERIPH_DISABLE} PERIPH_MODE; #define PARAM_PERIPHERAL_MODE(periph_mode) ((periph_mode == PERIPH_DISABLE) || (periph_mode == PERIPH_ENABLE)) /** * @brief clock config type definition */ typedef enum {CLK_4 = 0, CLK, CLK_2, CLK_8} PeripheralClock; #define PARAM_PERIPHERALCLOCK(State) ((State == CLK_4) || (State == CLK) || (State == CLK_2) || (State == CLK_8)) /** * @brief adc mode type definition */ typedef enum {POWER_DOWN_MODE = 0, OPERATIONAL_MODE = !POWER_DOWN_MODE} Adc_Mode; #define PARAM_ADCMODE(mode) ((mode == POWER_DOWN_MODE) || (mode == OPERATIONAL_MODE)) /** * @brief adc pin modes */ typedef enum {PULLUP = 0, REPEATER, NEITHER_PULLUP_NOR_PULLDOWN, PULLDOWN} Pin_Mode; #define PARAM_PinMode(mode) ((mode == PULLUP) || (mode == REPEATER) || (mode == NEITHER_PULLUP_NOR_PULLDOWN) || (mode == PULLDOWN)) void ADC_IRQHandler(void){ uint32_t data = (LPC_ADC->DR[0] >> 4) & 0xFFF; xprintf("data : %d \r\n", data); } void thermoController_adc_init(void){ // System Configuration for usign ADC. LPC_SYSCTL->PCLKSEL[0] |= (CLK_8 << 24);// Clock for adc peripheral is (system clock / 8) ==> 12 MHz LPC_SYSCTL->PCONP |= (PERIPH_ENABLE << 12); // Clock for adc peripheral enabled. // ADC pin configuration LPC_IOCON->PINSEL[1] |= (1 << 14); // AD0.0 is used as adc input. LPC_IOCON->PINMODE[1] |= (NEITHER_PULLUP_NOR_PULLDOWN << 14); // AD0.0 pin has neither pull-up nor pull-down resistor. // ADC Control Register Arrangement uint32_t ControlRegister = 0x01; ControlRegister |= (OPERATIONAL_MODE << 21); // PDN bit arrangement. ControlRegister |= (CLKDIV << 8); // CLKDIV is 119 for producing clock at 100 kHz for ADC. By using this value one value is taken per 650 us. LPC_ADC->CR = ControlRegister; // Update adc control register // Interrupt Configuration NVIC->IP[5] |= (32 << 19); NVIC->ISER[0] |= (1 << 22); LPC_ADC->INTEN |= (1 << 0); ControlRegister |= (1 << 24); // Start Conversion now. LPC_ADC->CR = ControlRegister; // Update adc control register for start conversion. } |
I would never use a xprintf from within a interrupt service routine. If this xprintf you are using
is from the standard library then you think about writing a mini-printf.
You are not resetting the NVIC pending bit in the interrupt routine.