We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I Good evening Everyone.
I am beginner for Programming of LPC2148.
I am making a project on transmitting temperature and location on my mobile by Bluetooth HC-05.
So I am using UART0 and ADC 0.6 such that Received data from GPS (NEO -6M) and ADC (LM35) will be transmitted to HC-05
Below is the program, I have written I am getting GPS data but no output from ADC0.6.
#include<lpc214x.h>void pll0(void);void uart0(void);char adc0_lm35(void);char gps_data(void);void message(char *ch);void tx(unsigned char a);void delay(int b);
int main(){ PINSEL0 = 0x00000305; char gps; char adc; while(1) { pll0(); uart0(); gps = gps_data(); adc = adc0_lm35(); message(&gps); message(&adc); }} void pll0(void) //setting PLL0 to generate 60Mhz Peripheral clock for UART0,UART1 and ADC0;{ PLL0CON = 0x01; //Enable PLL0 PLL0CFG = 0x24; //Configure PLL0 as P=2 and M=5 to generate PCLK = 60Mhz PLL0FEED = 0xAA; //PLLFEED sequence PLL0FEED = 0x55; //PLLFEED sequence if((PLL1STAT&0x0400)==0); //wait till PLL locks at 60Mhz PLL0CON = 0x03; //Enable and connect PLL PLL0FEED = 0xAA; //PLLFEED sequence PLL0FEED = 0x55; //PLLFEED sequence VPBDIV = 0x01; //VPB bus clock is same as processor clock}
void uart0(void) //setting baud rate to 9600 for gps in UART0{ U0LCR = 0x83; //world length 8bit, single stop bit, disable parity generator, odd parity, disable break transmittion, Enable Divisor latches U0DLL = 110; // load U0DLL = 110 U0DLM = 1; // load U0DLM = 1 U0FDR = (15<<4) | 1; //MULVAL = 15; Enable Divisor latches U0LCR &= 0x0F; // Disable Divisor latches }
char gps_data(void){ while((U0LSR & 0x01) == 0); return (U0RBR);}
void message(char *ch){ while(*ch!='\0') { tx(*ch); ch++; }}
void tx(unsigned char a){ while((U0LSR & 0x20) == 0); U0THR = a;}
void delay(int b){ T0CTCR = 0x00; T0PR = 12000000; T0TCR = 0x02; T0TCR = 0x01; while(T0TC<b); T0TCR = 0x00;}
char adc0_lm35(void){ char adc; while(1) { AD0CR=0x01201440; while(!(AD0GDR&0x80000000)); // Wait for the done bit to finish (using the general register) adc = ((AD0GDR>>6)&0x3FF); return (adc); }}
Rohit Jadhav said:I am beginner for Programming of LPC2148
Why start with such an old part?
See: community.arm.com/.../158931
And note that this has nothing to do with Keil or ARM - it's NXP you need to be asking about the specific operation of their chips:
https://community.arm.com/developer/tools-software/tools/f/keil-forum/43684/lpc2148-timer0-not-working-as-expected/158950#158950
https://community.nxp.com/
Do you have any experience with any other microcontroller(s) ?
Bluetooth communication is not a beginner's project!
For getting started with any microcontroller, see:
https://www.avrfreaks.net/comment/1138166#comment-1138166
thanks for your valuable input.
yes, I have made the project of led blink with button and timer on lpc2148. I have also made a project with turning on and off led with hc-05
https://www.youtube.com/watch?v=KkIPm2cjN-g
I am surely going to upgrade my self with the latest controllers but I am clearing my basics with lpc2148.