Department of Engineering Australian National University ENGN3213 Digital Systems & Microprocessors HLAB 6: ARM Embedded Systems I V3.0 Copyright 2010 G.G. Borg ANU Engineering 1
Contents 1 HLAB 6: ARM Embedded Systems 3 1.1 Aims....................................... 3 1.2 Background................................... 3 1.3 Using KEIL to Build Projects......................... 4 1.4 Downloading the HEX files to the board................... 5 2
1 HLAB 6: ARM Embedded Systems 1.1 Aims The aims for HLAB6 are, Become familiar with the LPC2368 ARM development board Look at the the implementation of a led flasher, beeper and web server 1.2 Background The range of ARM microprocessors on the market is absolutely stunning. The latest ARMS are the ARM7, ARM9 and lately the Cortex. Fig. 1 shows the NXP LPC2368 processor by Philips that is installed on the Futurlec ARM development board. The board is replete with functionality and in this lab we are going to downlad programs to the the lpc2368 to explore just some of these. The aim is to become familiar with the process without placing much emphasis on programming yet. To get the ball rolling download ARM_SOFTWARE.zip\endverbtaim from \beginverbatim http://engnet.anu.edu.au/decourses/engn3213/labs.html. The contents of this folder are as follows BEEP FlashMagic_Settings.jpg LED_Blink EasyWEB HEX files lpc2364.lpc2365.lpc2366.lpc2367.lpc2368.pdf flash magic HowTo_CP_JR_ARM7 LPC2368.doc User s Manual of CP_JR_ARM7_LPC2368.pdf KEIL_mdk411.exe where the folders BEEP, LED Blink and EasyWEB contain KEIL project files. The source is written in both C (.c and.h files) and assembler (.s). HEX files contains the HEX for download over the In circuit Serial Programming interface (ICSP). THE HEX files are readable and constitute the binary code load into flash memory in the processor 3
at the last stage of development. The program FlashMagic does the ICSP. The Users manual and how-to document provide a useful introduction to the experiments. The most important file is the KEIL Interactive Development Interface KEIL mdk411.exe. Download it and install it onto the PC immediately. 1.3 Using KEIL to Build Projects After installation run KEIL and go to Project and close anyn existing project. The under Project open a the BEEP project for which the source code in C is shown below. This code beeps the speaker periodically on the ARM board. Start by taking a look at the code. Note how the C code is quite readbable with some MACROS in assembly language. For example #define SPEAKER_ON() FIO2SET = SPEAKER where F IO2SET refers to an IO pin. Another simple observation is the way the speaker is delayed using a counter. /****************************************************/ /* Examples Program For "CP-JR ARM7 LPC2368" */ /* Target MCU : Philips ARM7-LPC2368 */ /* : X-TAL : 12.00 MHz */ /* : PLL Setup = MSEL(12),NSEL(1) */ /* Keil Editor : uvision3 V3.53a */ /* Compiler : Keil Realview MDK V3.20 */ /* Create By : Eakachai Makarn (WWW.ETT.CO.TH) */ /* Last Update : 12/November/2007 */ /* Function : Example Generate Beep on Speaker */ /****************************************************/ #include "LPC23xx.H" // LPC2368 MPU Register // Pin I/O Speaker Control Maskbit #define SPEAKER 0x00000100 // P2.8(0000 0000 0000 0000 0000 000x 0000 0000) #define SPEAKER_ON() FIO2SET = SPEAKER // Speaker Pin = 1 (ON LED) #define SPEAKER_OFF() FIO2CLR = SPEAKER // Speaker Pin = 0 (OFF LED) /* pototype section */ void delay(unsigned long int); // Delay Time Function int main(void) unsigned int beep_time; // Config Pin GPIO2[8] PINSEL4 &= 0xFFFCFFFF; // P2[8] = GPIO Function(xxxx xxxx xxxx xx00 xxxx xxxx xxxx xxxx) FIO2DIR = SPEAKER; // Set GPIO-2[8] = Output(xxxx xxxx xxxx xxxx xxxx xxx1 xxxx xxxx) SPEAKER_OFF(); // Default Speaker Status // Loop Generate Beep on Speaker(P2.8) while(1) // Loop Continue for (beep_time = 0; beep_time < 500; beep_time++) // Start Beep SPEAKER_ON(); // ON Speaker delay(5000); SPEAKER_OFF(); delay(5000); // OFF Speaker delay(10000000); // Stop Beep 4
/***********************/ /* Delay Time Function */ /* 1-4294967296 */ /***********************/ void delay(unsigned long int count1) while(count1 > 0) count1--; // Loop Decrease Counter Build the project by clicking on project Build Target. This produces a HEX file. Which should be able to locate in the project folder. Close the BEEP and repeat the same process for LED Blink and EasyWEB. Note the location of the HEX files. 1.4 Downloading the HEX files to the board First connect the serial (grey) cable from the PC sm serial port to the ARM board. Power up the ARM board and while depressing the ISP LOAD press once the RESET button. Finally releas the ISP LOAD button. This initialise the LPC2368 dfor download. Next open FlashMagic and make sure the settings are as shown in Fig 2. Browse to the BEEP HEX file and download it. When this is done and if this was successful then press the RESET button alone once more. If the download was not successful then double check the settings. The LP C2368 should immediately start to beep the on-board speaker. Note that if you power down the board and power up again the program should resume as it is stired permanently in flash. Repeat the above process with the LED blink HEX file. To test out EasyW EB you will first need to disconnect the PC s ethernet cable from the switch port on the desk and plug it into the ARM board s on-board ethernet port. Next go to the CMD prompt on the PC and type ipconfig/all. Note the IP address and net mask. Next go to the project file T CP IP.H and enter a different IP address for MY IP (say one that is one more than the PC s) and the same netmask. Rebuild the EasyWEB project in KEIL and download the HEX file to the board as above. If all is well the data leds near the ethernet port should be flashing. Open up FIREFOX on the PC and navigate to the URL http://ip_address_of_arm_bard. What do you see?? 5
Figure 1: The Philips NXP LPC2368 microprocessor. 6
Figure 2: The F lasmagic settings. 7