Professional Documents
Culture Documents
IDE and Flash magic in ARM Processor. Apparatus Required : ARM Processor kit Adapter USB Port THEORY : The ARM TDMI processor is a member of the ARM family of general purpose 32 bit microprocessor. The ARM family offers high Performance for low power Consumption. The ARM Architecture is based on RISC Principles. Its instruction set and related decode mechanism are much simpler than CISC design. This simplicity gives A High instruction throughput. An excellent real time interrupt response. A small & cost effective 1 1 1
Procedure : Type the program in notepad and save it in the folder along with the including files. Open the softawre Embest IDE and select the new workspace in file menu. Select add files to folder and open the program and save it. All the settings should be changed in the project dialog box. Switch on the kit and rebuild the program. Open the software Flash Magic and Browse the Program and click start. Change the Switch position and reset button. The output will be analyzed in the kit.
/***************************************************/ /* Read Room temperature from LM35 /* and display it on LCD /***************************************************/
#include "LPC214x.h"
/* LPC21xx definitions */
int main(void) { int a; unsigned char Channel = 1, t[7]; PINSEL1 = 0x01000000; InitializeLCD(); DisplayLCD(0,"Room Temperature"); while(1) { a=ReadADC(Channel); t[0] = a/100 + '0'; a -= (a/100) * 100; t[1] = a/10 + '0'; t[2] = '.'; t[3] = a%10 + '0'; t[4] = 'C'; t[5] = 0; DisplayLCD(1,t); LCDDelay1600(); } } // Display the room temperature // Read ADC channel 1 // Select ADC to pin P0.28 // Initialize LCD // Display message
//Read ADC data from given channel number int ReadADC(char ChannelNumber) { int val,ch;
ch = 1<<ChannelNumber;
do { val = AD0DR1; } while ((val & 0x80000000) == 0); val = ((val >> 6) & 0x03FF); // Wait for the conversion to complete // Extract the A/D result // Read A/D Data Register
return(val); }
/***************************************************/
#include "LPC214x.h"
/* LPC214x definitions */
void WriteCommandLCD(unsigned char CommandByte); void WriteDataLCD(unsigned char DataByte); void LCDDelay(void); void LCDDelay1600(void); void SendByte(unsigned char Value); void InitializeLCD();
void DataAddressDirection(void); void DisplayLCD(char LineNumber,char *Message); void DisplayLCD2Digit(char LineNumber,char CharPosition,char Data);
/* Initializes LCD */ void InitializeLCD() { DataAddressDirection(); IOSET0 = 0x00580000; // Set A0, A1, A2
WriteCommandLCD(0x38); LCDDelay1600();
WriteCommandLCD(0x38); LCDDelay();
WriteCommandLCD(0x38); LCDDelay();
WriteCommandLCD(0x0c); LCDDelay();
WriteCommandLCD(0x06); LCDDelay();
WriteCommandLCD(0x01); LCDDelay1600(); }
//Clear LCD
/* Writes a command byte to LCD */ void WriteCommandLCD(unsigned char CommandByte) { IOCLR1 = 0x03000000; SendByte(CommandByte); LCDDelay(); } //Small delay // Clear RS and RW
/* Send a byte of data to LCD */ void SendByte(unsigned char Value) { IOPIN1 &= 0xff00ffff; IOPIN1 |= Value << 16; IOSET0 = 0x00100000; IOCLR0 = 0x00480000; LCDDelay(); IOSET0 = 0x00580000; LCDDelay(); } /* Set A0, A1 & A2 to disable LCD */ /* Write data to data bus */ /* Generate chip enable signal for LCD */
/* Writes a Data byte to LCD */ void WriteDataLCD(unsigned char DataByte) { IOCLR1 = 0x01000000; IOSET1 = 0x02000000; SendByte(DataByte); LCDDelay(); } //Small delay /* clear RW */ /* Set RS */
/* Small delay */
for(a=0;a<0x1000;a++); }
for(a=0;a<0x050000;a++); }
WriteCommandLCD(0x0c); }
void DisplayLCD2Digit(char LineNumber,char CharPosition,char Data) { unsigned char a; if(LineNumber ==0) { //First Line a = 0x80; selection } else { //Second line a = 0xc0; selection } a+=(CharPosition); WriteCommandLCD(a); digit if( (Data & 0xf0) < 0xa0) { a = ((Data & 0xf0) >> 4) + '0'; } else { //Get the ASCII character //Check for less than 0xa0 //Calculate the character position //Send command to select the given //command for second line //command for first line
a = ((Data & 0xf0) >> 4) + 'A'- 0x0a; //Get the ASCII character } WriteDataLCD(a); if( (Data & 0x0f) < 0x0a) { a = (Data & 0x0f)+'0'; } else { a = (Data & 0x0f)+'A' - 0x0a; } WriteDataLCD(a); } //Get the ASCII character //Get the ASCII character //Display the first character //Check for less tham 0x0a
if(LineNumber ==0) { //First Line WriteCommandLCD(0x80); } else { //Second line //Select the first line
void DataAddressDirection(void) { IODIR0 |= 0x00580000; IODIR1 |= 0x03ff0000; } // Set A0, A1, A2 output lines
void __gccmain() {
Result : Thus the room temperature has been readed verified and validated by using open source software Embest IDE and magic in ARM processor.