salim1103
Newbie level 6
- Joined
- Nov 28, 2012
- Messages
- 12
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,349
Hi friends,
I am using 1k pot and led with lpc2129.if pot will varry led will be on and off.but output was not came.anybody can help me.here i atached my code .i am using p0.27 as pot (i.e internal adc)
#include <lpc21xx.h>
unsigned val = 0;
int main(void)
{
PINSEL1=0X004000000;
VPBDIV = 0x02; //Set the Pclk to 30 Mhz
IODIR1 = 0x00FF0000; // P1.16..23 defined as Outputs
PCONP|=0X00001000;
ADCR = 0x00270601; // Setup A/D: 10-bit AIN0 @ 3MHz
while(1)
{
ADCR |= 0x01000000; // Start A/D Conversion
PCONP&=~0X00001000;
do
{
val = ADDR; // Read A/D Data Register
}
while ((val & 0x80000000) == 0); //Wait for the conversion to complete
ADCR &= 0x00FFFFFF;
val = ((val >> 6) & 0x03FF)<<16; //Extract the A/D result
IOCLR1 = ~val; //write the result onto the LED pins
IOSET1=val;
}
}
I am using 1k pot and led with lpc2129.if pot will varry led will be on and off.but output was not came.anybody can help me.here i atached my code .i am using p0.27 as pot (i.e internal adc)
#include <lpc21xx.h>
unsigned val = 0;
int main(void)
{
PINSEL1=0X004000000;
VPBDIV = 0x02; //Set the Pclk to 30 Mhz
IODIR1 = 0x00FF0000; // P1.16..23 defined as Outputs
PCONP|=0X00001000;
ADCR = 0x00270601; // Setup A/D: 10-bit AIN0 @ 3MHz
while(1)
{
ADCR |= 0x01000000; // Start A/D Conversion
PCONP&=~0X00001000;
do
{
val = ADDR; // Read A/D Data Register
}
while ((val & 0x80000000) == 0); //Wait for the conversion to complete
ADCR &= 0x00FFFFFF;
val = ((val >> 6) & 0x03FF)<<16; //Extract the A/D result
IOCLR1 = ~val; //write the result onto the LED pins
IOSET1=val;
}
}