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" .
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"
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 delay(unsigned long int count1) { while(count1--); // Loop Decrease Counter }
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.