i am doing my project on LPC2148. when i interfaced the ADC AD0.1, there is no error while compiling. When the code is debugged the result is displaying in the global register and interrupt pin ADINT is showing "1" and the result appeared is zero. Please suggest any solution to this.
Another problem is that Lcd functions which refer to lcd.h included file are showing an error called " function declared implicitly" .
So do you have any good voltage reference? Do you have any voltage to measure? Do you have initialized all registers needed? Is the ADC powered? Do you start any conversion? ...
What makes your code different from the Keil reference code using the ADC? What makes your hardware different from the Keil evaluation boards?
sir, Thank you very much for your reply. According to the previous threads (posted by others), i modified my program. Now i debugged the code, getting the A/D conversion of the analog value provided in the keil peripheral window. But when i download this on to the board, the progam is stalled displaying nothing on LCD and it is not proceeding further. i am uploading the part of code.
/**************************************************************************************/ #include <LPC214x.h> #include <stdio.h> #include "arm2148_lcd.h"
#define led 0x0000000F //P0.0-3 (0000 00x0 0000 0000 0000 0000 0000 0000)
#define led_ON() IOSET0 = led #define led_OFF() IOCLR0 = led
void delay(unsigned long int); // Delay Function void adc(void ); int main() { PINSEL1 = 0x00000000; IODIR0 |= 0X0000000F; adc(); IODIR1 = 0x01FF0000; /* P1.16..23 defined as Outputs */ IODIR0 = 0x70000000; PINSEL1=0x00000000; RW_L;
Lcd4_Init();delay(65000); Lcd4_Display(0x80," CAN TX ",16);delay(65000); }
void delay(unsigned long int count1) { while(count1--); // Loop Decrease Counter }
void adc() { unsigned val; IODIR0 |= led; VPBDIV = 0X00000001; PINSEL1 |= 0x01000000; PCONP = 0X00001000; AD0CR &= 0X00000000; AD0CR |= 0X00000002; // selecting the channel AD0CR |= 0X00000300; // selecting clkdiv AD0CR |= 0X00001000; // selecting clks 9bits AD0CR |= 0X00200000; // selecting pdn AD0INTEN &= 0X00000000; delay(100); AD0CR |= 0x01000000 ; /* Start A/D Conversion */
while ((val & 0x80000000) == 0); /* Wait for end of A/D Conversion */ val=AD0DR1; val = ((val>>6) & 0x03FF); //masking instead of ADC data led_ON(); delay(8000000); led_OFF(); delay(8000000); }
#include <LPC214x.h> #include <stdio.h> #include "arm2148_lcd.h"
void delay(unsigned long int); // Delay Function void adc_init(void ); // adc initialisation void adc_read(void); // adc value read unsigned int vals; int main(void) { IODIR1 = 0x01FF0000; IODIR0 = 0xE1FF000F; PINSEL1=0x00000000; PINSEL0=0x00000000; PINSEL2=0x00000000; RW_L;
Lcd4_Init(); // lcd initialisation delay(65000);
VPBDIV = 0x00000001; //Set PClk to 14.75Mhz Lcd4_Display(0xc0,"ADC: ",16);
adc_init();
adc_read(); }
void adc_init() { VPBDIV = 0X00000001; PINSEL1 |= 0x01000000; // select P0.28 AD0.1 PCONP = 0X00001000; // Power up adc AD0CR &= 0X00000000; // clearing the ADC AD0CR |= 0X00000002; // selecting the channel AD0CR |= 0X00000300; // selecting clkdiv AD0CR |= 0X00001000; // selecting clks 9bits AD0CR |= 0X00200000; // deselecting pdm AD0INTEN &= 0X00000000; // disabling the interrupts }
void adc_read() { vals=0; AD0CR |= 0X01000000; // start conversion now do { vals= AD0DR1; // assign the value } while((AD0DR1 & 0X80000000)== 0); // check for done bit vals = ((AD0DR1>>6)); // shift the value vals &= 0X000003FF; AD0CR &= ~0x01000000; // stop conversion
if((vals > 100)&(vals<500)) { IOSET0 = 0X00000005; }
else if (500<vals<800) { IOSET0 = 0X00000007; delay(100000); IOCLR0 = 0X00000007; delay(100000); }
else if (vals<100) { IOSET0 = 0X00000003; } else IOSET0 = 0X00000009;
Lcd4_Decimal4(0xc5,vals) ;
}
May I recommend that you get a good book on the C programming language?
Not too many wants to read your code, since you didn't bother to check the posting instructions for source code - directly above the text input box.
Anyway:
if((vals > 100)&(vals<500)) { ... }
Are you really sure you should use & for your "and" expression? A good book on the C language could explain to you the difference between & and &&.
if (500<vals<800) { ... }
I don't think you picked up that expression in any good book on the C language. It does not mean what you think it does. Look closer in a book book on the C language about the precedence of operators and then try to figure out exactly what happens when that expression is seen. It is valid C code, but so very different from what you think...
So your program stalls? Wouldn't you say that a debugger would be a good too to use, to figure out where it stalls? Like in kind of looking inside the processor while the program is running? That is basically what a debugger is intended to do. Some debuggers are even quite good at it. How good is your debugger? Have you tested it yet? Programming isn't just about writing source code and getting it through the compiler. Specifications, debugging, formal testing, documentation, ... are also part of programmming.
Please sir/madam i want the adc interfacing lcd monitoring programe and synopsis and then report LPC 2148 ARM PROCESSOR pls help me.............!
No - your teacher want the [...]
But your teacher wants _you_ to perform the job.
By the way - I thought the correct spelling was "plz" and not "pls".