Hi, I have a problem with ADC initialization. The following part is draft needs to be filled with correct information Step by step according to the user manual. But I am not sure where I made mistake
void adc_init(void) { // set pin 4 (P0.11) as ADC // see page 94 // turn off all resistors on pin 4 // again on page 94 // Set the pin as analog mode (not digital) // Once again, page 94 // Enable the clock and power for ADC // Refer to pages 34 and 45 // the last two lines of code are supplied. // Enables AD[0], sets burst mode to 1 (hardware not software scan) // Also sets the clock speed to just under 4.5MHz LPC_ADC->CR|= (0x10A01); // check pages 410 -- 411 // According to datasheet, bit 8 of the register below must be set to 0 if in burst mode LPC_ADC->INTEN &= ~(1<<8); // check page 413 }
My code is
void adc_init(void) { // set pin 4 (P0.11) as ADC LPC_IOCON->R_PIO0_11 |=(0x2); // see page 94 // turn off all resistors on pin 4 LPC_IOCON->R_PIO0_11 &= ~(1<<4); LPC_IOCON->R_PIO0_11 &= ~(1<<3); // again on page 94 // Set the pin as analog mode (not digital) LPC_IOCON->R_PIO0_11 &= ~(1<<7); // Once again, page 94 // Enable the clock and power for ADC // Refer to pages 34 and 45 // the last two lines of code are supplied. LPC_SYSCON->PDRUNCFG &= ~(0x1<<4); LPC_SYSCON->SYSAHBCLKCTRL |= (1<<13); //enable clock for ADC (sec. 3.5.14) // Enables AD[0], sets burst mode to 1 (hardware not software scan) // Also sets the clock speed to just under 4.5MHz LPC_ADC->CR|= (0x10A01); // check pages 410 -- 411 // According to datasheet, bit 8 of the register below must be set to 0 if in burst mode LPC_ADC->INTEN &= ~(1<<8); // check page 413 }
User Manual For the lpc1114 www.nxp.com/.../UM10398.pdf