plz help me on this code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

plz help me on this code

429 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by navidrct on Wed Jun 10 23:44:58 MST 2015
hi
what lib should i include to use LPC_ADC instruction?
what is 1UL in this code?what does it mean?
im new in this.if u can comment this code more than this i apericiate it
thanks

        LPC_ADC->ADCR = 0; // Power AD down
 LPC_SC->PCONP |= (1 << 12); // Enable power to AD block
LPC_SC->PCLKSEL0 &= ~(1<<24); // clock 25 MHz
LPC_SC->PCLKSEL0 &= ~(1<<25);
LPC_ADC->ADCR = 7 << 8; // conversion clock = 100 Mhz / 8 [7+1] = 12.5 MHz
LPC_ADC->ADCR |= (1<<21); // PDN = set AD operational
LPC_ADC->ADCR |= (1<<0); // SEL = select AD0.0 to start

int Good = 1;
int Bad = 0;
while(1)
{
LPC_ADC->ADCR |= (1<<24); // START = start conversion now
while (!(LPC_ADC->ADGDR & ( 1UL << 31)))
;  /* Wait for Conversion end       */
int value = (LPC_ADC->ADDR0 >> 4) & 0xFFF;
if((value < 0x580) || (value > 0x5FF))
Bad++;
else
Good++;
double pct = (double)Bad * 100 / (double)Good;
Debug("AN0 = %X good %5d bad %5d %.02f%%", value, Good , Bad, pct);
os_dly_wait(25);
}
Labels (1)
0 Kudos
2 Replies

404 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by navidrct on Thu Jun 11 02:12:25 MST 2015

Quote: TheFallGuy
You need to be using LPCOpen. Start by reading the LPCOpen docs for your target
http://www.lpcware.com/content/project/lpcopen-platform-nxp-lpc-microcontrollers/lpcopen-v200-quicks...
http://www.lpcware.com/lpcopen

1UL is standard C. It means "the value 1 typed as an unsigned long". Get yourself a good C book...


thanks.i'll check it
0 Kudos

404 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu Jun 11 01:06:28 MST 2015
You need to be using LPCOpen. Start by reading the LPCOpen docs for your target
http://www.lpcware.com/content/project/lpcopen-platform-nxp-lpc-microcontrollers/lpcopen-v200-quicks...
http://www.lpcware.com/lpcopen

1UL is standard C. It means "the value 1 typed as an unsigned long". Get yourself a good C book...
0 Kudos