Documente Academic
Documente Profesional
Documente Cultură
ELECTRONICS HUB
P R OJ E C T S | T U TO R I A L S | C O U R S E S
Contents [hide]
1 Circuit Diagram
2 Components Required
3 Circuit Design
4 Working of the Project
5 Code
6 Understanding the Program
7 Applications
8 Related Articles
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 1/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
Bluetooth has a wide range of applications like data transfer, wireless music, device control
etc. The reason Bluetooth is used in such applications is its ease of implementation, low power
consumption and the most important thing is its availability i.e. almost all mobile phone
(whether it may a simple feature phone or an advanced smart phone) is equipped with
Bluetooth.
ARM 7 based LPC2148 is one of the successful and popular 32 bit microcontrollers. It has
many on chip features. But today, we are going to concentrate on the serial communication
i.e. UART feature of the LPC2146 MCU.
StartDownloadPDFNow
ConvertFromDoctoPDF,PDFtoDocSimplyWith
TheFreeOnlineApp!
fromdoctopdf.com
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 2/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
In this project, we are going to interface the Bluetooth module with the ARM 7 based MCU i.e.
LPC2148. In the later projects, we will use this interface and develop some advanced projects.
One of the major applications of Bluetooth module is in the eld of Home Automation and
Smart Home systems, where a Bluetooth enabled device like a smart phone or tablet can be
used to control the smart home application.
Circuit Diagram
Components Required
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 3/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
Since we are using the LPC2148 development board in this project, some of the mentioned
components might already be embedded on to the board. The components required for the
implementation of the project are as follows:
Circuit Design
The circuit design for the interface of Bluetooth Module with LPC2148 involves the connection
between the HC 05 Bluetooth Module and the ARM7 based MCU LPC2148. The details of the
complete circuit design are as follows.
The HC 05 Bluetooth module is an UART based device. Hence, the connection between the
LPC2148 and Bluetooth module requires only two wires. In LPC2148, there are two UART
modules: UART 0 and UART 1. The UART 0 in our development board is connected to the USB
to serial converter.
So, we are connecting the Bluetooth Module to the UART 1 i.e. PORT0 Pins P0.8 (Pin 33) and
P0.9 (Pin 34). The TX pin of the Bluetooth Module is connected to RXD1 (P0.9 Pin 34) of
LPC2148. Similarly, the RX pin of the Bluetooth Module is connected to TXD1 (P0.8 Pin 33) of
LPC2148.
Note: The TX and RX pins of Bluetooth Module can tolerate only 3.3V. Since the output of the
LPC2148 MCU is only 3.3V, the connections can be made directly.
The Bluetooth Module has on board 3.3V regulator. So, 5V supply can be given to the
module.
On the development board, the LEDs are connected to PORT1 Pins P1.18 to P1.25. So, we will
write the program as per these pins.
The project successfully demonstrates the interface of Bluetooth Module with LPC2148. It
involves the UART Module of the LPC2148. So, it is advised to read our UART tutorial for
LPC2148 MCU.
As mentioned in the circuit design, the Bluetooth Module is connected to UART 1 module in
the LPC2148. When the Bluetooth module is successfully paired with the smart phone, we can
con gure the application in the phone to transmit the desired data.
In the program, it is con gured that when 0 is received by the Bluetooth Module, all the LEDs
that are connected as per the circuit diagram will be turned ON. Similarly, when 1 is received,
all the LEDs will be turned OFF.
So, it is important to con gure the UART module properly. Also, the PLL module is used to
generate CCLK and PCLK. The con guration of PLL module and other related information are
explained in our ARM PLL Tutorial.
Code
1 #include<lpc214x.h>
2
3 #defineCLK_DIV(151)
4 #definePowerUP(1<<21)
5 #defineSel_ADC_Cha(1<<1)
6 #defineADC_START(1<<24)
7 #defineADC_DONE(1<<31)
8
9 voidinitPLL(void);
10 voidinitPWM(unsignedintperiodPWM);
11 voiddelay(int);
12
13 voidinitPLL(void)
14 {
15 PLL0CON=0x01;
16 PLL0CFG=0x24;
17 PLL0FEED=0xAA;
18 PLL0FEED=0x55;
19 while(!(PLL0STAT&0x00000400));
20 PLL0CON=0x03;
21 PLL0FEED=0xAA;
22 PLL0FEED=0x55;
23 VPBDIV=0x01;
24 }
25
26 voiddelay(intd)
27 {
28 unsignedinti,j;
for(j=0;j<d;j++)
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 5/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
29
30 {
31 for(i=0;i<10;i++);
32 }
33 }
34
35 voidinitPWM(unsignedintperiodPWM)
36 {
37 PINSEL0=0x00000002;
38 PWMTCR=(1<<1);
39 PWMPR=0X00;
40 PWMMCR=(1<<0)|(1<<1);
41 PWMMR0=periodPWM;
42 PWMLER=(1<<0);
43 PWMTCR=(1<<0)|(1<<3);
44
45 }
46
47 intmain()
48 {
49 intdutycycle;
50 unsignedshortintadcResult;
51 initPLL();
52 PINSEL1=0x01000000;
53 AD0CR=((CLK_DIV<<8)|PowerUP);
54 initPWM(255);
55 PWMPCR|=(1<<9);
56 while(1)
57 {
58 AD0CR|=Sel_ADC_Cha;
59 delay(10);
60 AD0CR|=ADC_START;
61 while((AD0DR1&ADC_DONE)==0);
62 adcResult=(AD0DR1>>6)&0x3ff;
63 AD0CR&=~(ADC_START);
64 dutycycle=adcResult/4;
65 PWMMR1=dutycycle;
66 PWMLER|=(1<<1);
67 }
68 }
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 6/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
First is the PLL0 module. PLL0 module is con gured to generate the system clock i.e. CCLK at
60 MHz. So, we will enable the PLL0 module and also set the multiplier and divider values. In
order to do that, we will use the following commands.
PLL0CON = 0x01;
PLL0CFG = 0x24;
Once the PLL0 module in initialized and the multiplier and divider values are set, the next step
is to x these multiplier and divider values. For this, we will use the following feed sequence.
PLL0FEED = 0xAA;
PLL0FEED = 0x55;
Now, we will check if the PLL0 module is locked to the speci ed values with the help of
PLL0STAT register and once it is locked, we will connect the PLL module.
PLL0CON = 0x03;
Another Feed sequence is written to lock the PLL0 module. Now, the CCLK will oscillate at 60
MHz.
PLL0FEED = 0xAA;
PLL0FEED = 0x55;
Finally, the peripheral clock is con gured to replicate the system clock.
VPBDIV = 0x01;
The next module we are going to discuss is the UART module. As mentioned earlier, we are
using the UART1 module in the project.
So, the rst step is to select the TX1 and RX1 pins using the PINSEL register.
PINSEL0 = 0x50000;
We need to set the UART frame format for data transmission. With the following instruction,
we will set it as 8 Data bits, no Parity bits and 1 Stop bit.
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 7/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
U1LCR = 3 | (1<<7);
We need to set the Baud Rate to 9600 bps. For that, the DLL and DLM values are set as
follows.
U1DLL = 110;
U1DLM = 1;
Now, for more accurate baud rate, the Mulval and Divval values are set.
All the values are locked using the following command. Also the RX and TX FIFO is enabled for
data transmission and reception.
U1FCR = 0xC1;
With these commands, the UART is setup successfully and is ready to receive and transmit
the data. The next step is to read the received data and turn the LEDs ON or OFF.
char c = UART1Read();
if( c == 0 )
IO1SET = 0x03FC0000;
else if (c == 1)
IO1CLR = 0x03FC0000;
Applications
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 8/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
Related Articles
Bluetooth Controlled How to Connect Arduino ARM PLL Tutorial Arduino Home
Electronic Home Uno to Android via Automation Using RF
Appliances Bluetooth
Interfacing 16X2 LCD Basic ARM Tutorials For ARM Introduction ARM GPIO Introduction
Beginners
Download
Zip,UnziporOpenAnyFile
WithUnzipper.Goto
unzipper.com
StartDownload
PDFNow
ConvertAnyFiletoaPDF.Get
theFreeFromDoctoPdfApp!
Gotofromdoctopdf.com
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 9/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
Leave a Reply
Your email address will not be published. Required elds are marked *
Comment
Name *
Email *
Website
POST COMMENT
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 10/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
adsbymedia.net
DeviceManagementSolution
SecuritySystemKeypad
NetworkMonitoringDevice
Bluetooth2.0Module
DataDevices
WirelessPCCardForDesktop
SetupVOIPPhoneSystem
ElectronicsHub
YouTube 12K
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 11/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
ElectronicsHub
FollowOn
Electronics Hub
Follow +1
+ 76,094
SUBSCRIBE
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 12/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
Delivered by FeedBurner
ElectronicsHub
655,239likes
LikePage SignUp
4friendslikethis
adsbymedia.net
ComputerProtocol
USBEncryption
WirelessPCCardForDesktop
USBMemoryDevice
WirelessAudio/VideoReceiver
SetupVOIPPhoneSystem
MobileDeviceSecuritySystems
GarminPCInterfaceCable
TransmissionControlModule
AllworxPhoneSystems
AutomationApplication
DellBluetoothModule
BluetoothTechnology
BluetoothSoftware
Wireless360ModuleWithBluetooth
PROJECTS BY CATEGORY
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 13/15
2/2/2017 InterfacingBluetoothwithARM7LPC2148
IOT
TUTORIALS
Capcitors
Resitors
Filters
Diodes
Transistors
TUTORIALS FOLLOW US
IO Devices Youtube
DC Circuits Twitter
Nummber System
http://www.electronicshub.org/interfacingbluetootharm7lpc2148/ 15/15