Download as pdf
Download as pdf
You are on page 1of 22
The ARM7 LPC2148 Primer board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port NXP’s ARM7 (LPC2148), ARM Primer Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 32-bit Microcontrollers, 2c dnteraterated Cia) The I2C (Iater-IC) bus is a bi-directional two-wire serial bus that provides a communication link between integrated circuits (ICs).I2C is a synchronous protocol that allows a master device to initiate communication with a slave device. Data is exchanged between these devices. [RIC (Rea Time Clock) The DS1307 Serial Real-Time Clock is a low-power: full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially via a 2- wire, bi-directional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12- hour format with AM/PM indicator. Interfacing BC-RIC Fig. 1 shows how to interface the RTC with microcontroller through I2C. 12C is a Master-Slave protocol, I2C has a clock pulse along with the data. The master device controls the clock line, ‘SCL. This line dictates the timing of all transfers on the I2C bus. No data will be transferred unless the clock is manipulated. 12c bus supports many devices, each device is recognized by a unique address—whether it’s a micro-controller, LCD Driver, memory or keyboard interface and can operate as transmitter or receiver based on the functioning of the device. The controller designed controls the RTC 51307 device through I2C protocol. The I2C Controller here acts as a master device and controls RTC ds1307 which acts as a slave. The read operation is accomplished by sending a set of control signals including the address and/or data bits. The control signals must be accompanied with proper clock signals. Vee vay Vee peu pp RPU Wb Fig. | Interfacing I2C - RTC to Microcontroller Interfacing BC RTE with LPC2I48 Read date & time by using I2C - RTC in LPC2148 Primer Board. Wiring up an 12C based RTC to the I2C port is relatively simple. The RTC also makes the software easier as it takes care of all calendar functions; accounting for leap years etc. The DS1307 (RTC) Real Time Clock IC (an 12C real time clock) is an 8 pin device using an I2C interface. In LPC2148 Primer Kit, 2 nos. of RTC lines are controlled by I2C Enabled drivers. I2C Lines serial clock SCL (P0.2), serial data SDA (P0.3) connected to the I2C based serial RTC ds1307 IC. The date & times are read in LPC2148 Primer Kit by using these SDA & SCL 12C lines. Py Assignment with LPCIAS | 12C RTC [Lpcaias Lines | Real Time Clock | SCL. {sci - (PO.11) DS1307 (oc | SDA. ‘spa = (P0.14) Das Sores Code The Interfacing I2C — RTC with LPC2148 program is very simple and straight forward that read date & time in RTC by using I2C & the value is displayed in serial port. A delay is occurring in every single data read from RTC. The delay depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes. (CPromzam to interface 2 -RTC with LPC2S Title : Program to read date & time of RC - RTC #inolude #inolude #include #include #include #include "UART.h" define MAX 8 #define AA 2 idefine SI 3 idefine STO 4 #define STA 5 #define I2EN 6 #define ESC 0x1B idefine SW3 1<<24 idefine SW4 1<<25 Hdefine SWS 1<<26 void 12C_ISR(void)_irq; void UARTO_ISR (void) _ ira; void Wait (unsigned int); void 12C_Init (void); int I2C_Start (void); int 2C_Write (unsigned char “Buff, unsigned int Count); char Buff[MAX]=(0x59,0x58, 0x65,0x04,0x04,0x11 0x09}; unsigned char Day(7][10]={"Sunday”, "Monday", "Tuesday’,"Wednesday’”, "Thursday", "Friday’, "Saturday’}; unsigned char Rec[MAX] = {"NO-DATA"}; unsigned char index = 0; unsigned char flag = 0, Ready=0; int ii=0; char Key; void I2C_ISR(void)__irq { if (I2C1CONSET & 0x08) { switch (I2C1STAT) { case (0x08): if (flag { I2C1CONCLR = 1< Tum SW3 ON and Check Hyperteminal to Set Time...\n\"); UARTO_Puts (‘in\r, iin: Wait (6000); flag = W’ 12C_Start (); for (i=0;i<30\i++) Wait(10000); I2C1CONCLR = 1<> 4)"10| (BCD & Ox0F); return HEX; void serial_init(void) { PINSELO |= 0x00000005; UOLCR = 0x83; UODLL = 195; UOLCR 1x03: To compile the above C code you need the KEIL software. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project. In Keil, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without LPC2148 Primer Board. ‘The Flash Magic software is used to download the hex file into your microcontroller IC LPC2148 through UARTO. Testing the 2C- RTC with LEC2L48 Give +3.3V power supply to LPC2148 Primer Board; the RTC Battery device is connected with the LPC2148 Primer Board. First check the entire Battery device fixed properly. A serial cable is connected between the microcontroller and PC. In PC, open the Hyper Terminal for displaying the values from RTC. Now, the Hyper Terminal shows the received data from RTC Battery through I2C. If you want to change the time value from RTC Battery then you just Turn ON the switch, sw3. Now, you can write any new time values into the RTC by using Hyper Terminal. Then Turn OFF switch, sw3. Now the RTC Battery start the new time value & it display in Hyper Terminal. The Hyper Terminal is working but it is not reading any value from LPC2148 Primer Board, then you just check the jumper connections. Change the Battery & ds1307 device.

You might also like