hello
I’m using the LPC2148 CodeBase v0.1 from microbuilder.eu (- j.c.wrens version adapted to crossworks from rowley).
For the project I extended the library for all 4 ADCs I need: AD0.1, AD0.2, AD1.6, AD1.7.
Everyone works fine, except the AD1.7 (posted below). First time through there is no problem, the second time it hangs in the ```
while (!(AD1_DR7 & AD_DR_DONE))
library
int adcInit1_7 (void)
{
// Force pin 0.22 to function as AD1.7
PCB_PINSEL1 = (PCB_PINSEL1 & ~PCB_PINSEL1_P022_MASK) | PCB_PINSEL1_P022_AD17;
// Enable power for ADC1
SCB_PCONP |= SCB_PCONP_PCAD1;
// Initialise ADC converter
AD1_CR = AD_CR_CLKS10 // 10-bit precision
| AD_CR_PDN // Exit power-down mode
| ((11 - 1) << AD_CR_CLKDIVSHIFT) // 4.36MHz Clock (48.0MHz / 11)
| AD_CR_SEL7; // Use channel 3
return 0;
}
int adcRead1_7 (void)
{
// Deselects all channels and stops all conversions
AD1_CR &= ~(AD_CR_START_MASK | AD_CR_SELMASK);
// Select channel 7
AD1_CR |= (AD_CR_START_NONE | AD_CR_SEL7);
// Manually start converting now (rather than waiting on an external input)
AD1_CR |= AD_CR_START_NOW;
// Wait for the conversion to complete
while (!(AD1_DR7 & AD_DR_DONE))
;
// Return the processed results
return ((AD1_DR7 & AD_DR_RESULTMASK) // Read bits 6…15 on AD1 data register 6 (which contains our conversion results)
>> AD_DR_RESULTSHIFT); // shift them to the end of a 32-bit value (giving us a 10-bit number)
}
any idea?