You are on page 1of 47

ABOUT KEILVISION SOFTWARE

CONFIGURING KEIL VISION3 Abstract: This article gives a step-by-step procedure for starting a project and configuring the Keil Vision IDE software for the MAX7651 EV kit. It is the second of a three-part application example for writing, compiling and downloading a simple program to the MAX7651 EV kit target board. Procedure 1. Download and install the Keil DK-51 demo software at www.keil.com unless it was installed previously as a step in application note 3083, "Performing ADC Conversions Using the MAX7651." Note: Please verify that you are using version 7.08 or later. The procedure for the software installation is outlined in the MAX7651 Quick Start Manual. 2. Open Keil Vision 2 by clicking on the Keil icon on your desktop or by opening the software in the Windows START menu. Open a new project in the Keil Vision IDE Software

Select a new folder and give the project a name. Select MAX7651 target in the database under Maxim -> MAX7651. Click OK. Click Yes, to "Copy Standard 8051 Startup Code to Project Folder and Add File to Project". Right Click on Target 1 -> Source Group 1 and Add files to Source Group 1.

1. Add the source files. See, application note 3083, "Performing ADC Conversions Using the MAX7651."

Set Target Options. Click on the icon to the left of Target drop down box. Click on the Target Tab. Configure the Target for an 11.0592MHz crystal, select Use On-Chip ROM (0x0-0x3FFF), specify Off-chip Code Memory to Start at 0x4000 with a size of 0x8000 and Off-Chip Xdata memory to Start at 0x0 with a Size of 0x8000.

1. 2. Set output options. Click on Create HEX file.

Set Debug Options. Check the Use Simulator option.

3. Click OK to accept option changes. 4. In the Project Menu, Select Rebuild all Target Files. The Program should compile. 5. Make sure there are no errors. The Program is ready to be loaded to the MAX7651 Target Board. See, application note 3087, "Downloading a Program to Flash Using the MAX7651 EV Kit Serial Downloader."

6. If you do not have the MAX7651EVKIT and/or wish to run the program using the Keil Vision simulator, click on the Debug Menu, and Start the debug Session. Click OK for the warning of evaluation version. Select View Menu and click on Serial Window #1. Select the Debug Menu and click on Go. The program will execute and perform analog-

to-digital conversions on all 8 channels.

ABOUT FLASH MAGIC


FLASH PROGRAMMING UTILITY 1. NXP (Philips)
NXP Semiconductors produce a range of Microcontrollers that feature both on-chip Flash memory and the ability to be reprogrammed using In-System Programming technology. Flash Magic is Windows software from the Embedded Systems Academy (www.flashmagictool.com) that allows easy access to all the ISP features

provided by the devices. These features include: Erasing the Flash memory (individual blocks or the whole device) Programming the Flash memory Modifying the Boot Vector and Status Byte Reading Flash memory, Reading the signature bytes Performing a blank check on a section of Flash memory Reading and writing the security bits

Hyper Terminal Window Setup

Flash Magic provides a clear and simple user interface to these features and more as described in the following sections. Under Windows, only one application may have access the COM Port at any one time, preventing other applications from using the COM Port. Flash Magic only obtains access to the selected COM P ort when ISP operations are being performed. This means that other applications that need to use the COM Port, such a s debugging tools, may be used while Flash Magic is loaded.

Programming Mode

Switch Push to ON, MCU enters programming mode. Execution Mode

Switch Push to OFF, MCU turns to execution mode. On-board Peripherals The Development board comes with many interfacing options 8 Nos. of Point LEDs 8-Input DIP Switch 2 Lines X 16 Character LCD Display. Real Time Clock with battery backup. 8 Channel, 10- Bit Analog to Digital Converter. 4 Nos. of Seven-segment display. RS232 Serial Interface. Digital Temperature Sensor 32k External SRAM/Flash

4 X 4 Matrix keyboard. Motor driver circuit. Alarm interface

ABOUT KEILVISION SOFTWARE


CONFIGURING KEIL VISION3 Abstract: This article gives a step-by-step procedure for starting a project and configuring the Keil Vision IDE software for the MAX7651 EV kit. It is the second of a three-part application example for writing, compiling and downloading a simple program to the MAX7651 EV kit target board. Procedure 7. Download and install the Keil DK-51 demo software at www.keil.com unless it was installed previously as a step in application note 3083, "Performing ADC Conversions Using the MAX7651." Note: Please verify that you are using version 7.08 or later. The procedure for the software installation is outlined in the MAX7651 Quick Start Manual. 8. Open Keil Vision 2 by clicking on the Keil icon on your desktop or by opening the software in the Windows START menu. 9. Open a new project in the Keil Vision IDE Software

10. Select a new folder and give the project a name. 11. Select MAX7651 target in the database under Maxim -> MAX7651. Click OK. 12. Click Yes, to "Copy Standard 8051 Startup Code to Project Folder and Add File to Project". 13. Right Click on Target 1 -> Source Group 1 and Add files to Source Group 1.

14. Add the source files. See, application note 3083, "Performing ADC Conversions Using the MAX7651."

15. Set Target Options. Click on the icon to the left of Target drop down box. Click on the Target Tab. Configure the Target for an 11.0592MHz crystal, select Use On-Chip ROM (0x0-0x3FFF), specify Off-chip Code Memory to Start at 0x4000 with a size of 0x8000 and Off-Chip Xdata memory to Start at 0x0 with a Size of 0x8000.

16. Set output options. Click on Create HEX file.

17. Set Debug Options. Check the Use Simulator option.

18. Click OK to accept option changes. 19. In the Project Menu, Select Rebuild all Target Files. The Program should compile. 20. Make sure there are no errors. The Program is ready to be loaded to the MAX7651 Target Board. See, application note 3087, "Downloading a Program to Flash Using the MAX7651 EV Kit Serial Downloader."

21. If you do not have the MAX7651EVKIT and/or wish to run the program using the Keil Vision simulator, click on the Debug Menu, and Start the debug Session. Click OK for the warning of evaluation version. Select View Menu and click on Serial Window #1. Select the Debug Menu and click on Go. The program will execute and perform analog-to-digital conversions on all 8 channels.

ABOUT FLASH MAGIC


FLASH PROGRAMMING UTILITY 1. NXP (Philips)
NXP Semiconductors produce a range of Microcontrollers that feature both on-chip Flash memory and the ability to be reprogrammed using In-System Programming technology. Flash Magic is Windows software from the Embedded Systems Academy (www.flashmagictool.com) that allows easy access to all the ISP features

provided by the devices. These features include: Erasing the Flash memory (individual blocks or the whole device) Programming the Flash memory Modifying the Boot Vector and Status Byte Reading Flash memory, Reading the signature bytes Performing a blank check on a section of Flash memory Reading and writing the security bits

Hyper Terminal Window Setup

Flash Magic provides a clear and simple user interface to these features and more as described in the following sections. Under Windows, only one application may have access the COM Port at any one time, preventing other applications from using the COM Port. Flash Magic only obtains access to the selected COM P ort when ISP operations are being performed. This means that other applications that need to use the COM Port, such a s debugging tools, may be used while Flash Magic is loaded.

Programming Mode

Switch Push to ON, MCU enters programming mode. Execution Mode

Switch Push to OFF, MCU turns to execution mode. On-board Peripherals The Development board comes with many interfacing options 8 Nos. of Point LEDs 8-Input DIP Switch 2 Lines X 16 Character LCD Display. Real Time Clock with battery backup. 8 Channel, 10- Bit Analog to Digital Converter. 4 Nos. of Seven-segment display. RS232 Serial Interface. Digital Temperature Sensor 32k External SRAM/Flash 4 X 4 Matrix keyboard. Motor driver circuit. Alarm interface

Board layout

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE: ___________________________________________________________________________ Aim: Write a C program to send data serially through serial port. Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3,flash magic Program: #include<REG51.h> #include<stdio.h> void serial_init(void); void serial_init(void) { SCON=0X50; TMOD=0X20; TH1=0XFD; TR1=1; TI=1; } void main(void) { serial_init(); while(1) printf("Hello! world\n"); } Date: ...........................

Output:

Result: Thus the program to send data serially through serial port was executed successfully and got the desired output.

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE: Aim: Write a C program to receive data serially. Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3, flashmagic Program: #include<reg51.h> void serial(void); void DelayMS(unsigned int); unsigned int i,j; unsigned char b[25],d; void main() { EA=1; ES=1; serial(); while(1); } void serial(void) { TMOD=0x20; SCON= 0X50; TH1=0XFD; TR1=1; } void serin(void) interrupt 4 { if(RI==1) { d=SBUF; b[j]=d; SBUF=b[j]; DelayMS(20); j++; } SCON=0X50; } void DelayMS(unsigned int k) { unsigned int; Date: ...........................

for(i=0;i<k;i++); } Output:

Result: Thus the program to receive data serially was executed successfully and got the desired output.

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE: Aim: Write a program for the LED to glow from right to left. Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3, flashmagic Program: #include<reg51.h> void delay(); void main() { int i; while(1) { for(i=0x01;i<=0xFF;i++) { P0=i; delay();}}} void delay() { unsigned int i; for(i=0;i<=5;i++) { TMOD=0X06; TL0=0X00; TH0=0X00; TR0=1; TR0=0; }} Date: ...........................

Output:

Result: Thus the program the LED to glow from right to left serial port was executed successfully and got the desired output.

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE: Aim: Write a C program to display a message on LCD. Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3,flashmagic Program: #include<reg51.h> #include<stdio.h> #define data P1 sbit RS=P3^5; sbit RW=P3^6; sbit EN=P3^7; code unsigned char msg[]=("WELCOME 2 JBREC"); code unsigned char msg1[]=("ES"); void lcd_init(void); void lcd_cmd(unsigned char); void lcd_display(unsigned char); void delay(int); void lcd_cmd(unsigned char cmd) { data=cmd; RS=0; RW=0; EN=1; delay(35); EN=0; } Date: ...........................

void lcd_display(unsigned char dat) { data=dat; RS=1; RW=0; EN=1; delay(35); EN=0; } void delay(int k) { unsigned int a; for(a=0;a<k;a++); } void lcd_init(void) { unsigned char i; lcd_cmd(0x38);delay(15); lcd_cmd(0x0C);delay(15); lcd_cmd(0x06);delay(15); lcd_cmd(0x01);delay(15); lcd_cmd(0x80); delay(15); i=0; while(msg[i]!='\0') { lcd_display(msg[i]); i++; } delay(50); lcd_cmd(0xC0); delay(15); i=0; while(msg1[i]!='\0') { lcd_display(msg1[i]); i++; } delay(50); } void main() { lcd_init(); delay(50); while(1); }

Output:

Result: Thus the program to display a message on LCD was executed successfully and the following message is displayed on LCD.
WELCOME 2 JBREC ES

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE:: Aim: Write a C program to to read Analog signals from ADC. Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3,flashmagic Program: #include<stdio.h> #include <reg51.h> #include <ctype.h> sbit A0 = P2^7; sbit A1 = P2^6; sbit A2 = P2^5; sbit CS = P2^4; void serial(); void delay1(int); void delay2(int); unsigned char READ_ADC(void); unsigned char ch; unsigned int i; void delay1(int n) Date: ...........................

{ int i; for(i=0;i<n;i++); } void delay2(int n) { int i; for(i=0;i<n;i++) delay1(1000); } void serial() { SCON=0x50; TMOD=0x20; TH1=0xfd; TR1=1; TI=1; } unsigned char READ_ADC() { unsigned char ADC_DATA; CS = 0; delay2(1); CS = 1; delay2(1); CS = 0; delay2(1); CS = 1; delay2(1); ADC_DATA = P1; return(ADC_DATA); } void main(void) { P1=0xFF; serial(); A0 = 0; A1 = 0; A2 = 0; printf("ADC Demo - Channel '0' Adjust (R27) Trimpot\n"); printf("--------------------------------------------\n"); while(1) { ch = READ_ADC(); printf("\rCH0 = %3bu",ch); delay2(2); } }

Output:

Result: Thus the program to display value in Port1 is converted to decimal value and Obtained desired results.

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE:: Aim: Write a C program to Digital to Analog Conversion Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3,flashmagic Program: #include<reg51.h> sfr dacdata=0X90; void main() { unsigned char pulse[13]={128,192,238,255,238, 192,128,64,17,0,17,64,128}; Date: ...........................

unsigned char x; dacdata=0X00; while(1) { for(x=0;x<13;x++) { dacdata=pulse[x]; } } }

output

Result: Thus the program to display digital value converted in to Analog value and Obtained desired results.

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY

Expt. No: TITLE::

Date: ...........................

Aim: Write a C program to to read data from keypad interface and display on LCD. Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3,flashmagic Program: #include <stdio.h> #include <reg51.h> #define DATA P1 void lcd_init(void); void lcd_cmd(unsigned char); void lcd_display(unsigned char); void Key_Scan(void); void DelayMs(int); sbit RS = P3^5; sbit RW = P3^6; sbit lcd_e = P3^7; unsigned char R,C,ch,d=0x81; unsigned int i=0; unsigned char Key[4][4] = {'C','D','E','F','8','9','A','B','4','5','6','7','0','1','2','3',}; code unsigned char msg[] = ("KEYPAD TEST PGM "); code unsigned char msg1[] = ("PRES ANY KEY... "); void main() { lcd_init(); DelayMs(20); lcd_cmd(0x01); lcd_e=0; lcd_cmd(0x80); while(1) { Key_Scan(); lcd_e=1; DelayMs(5); ch = Key[R][C]; DelayMs(5); lcd_cmd(d++); DelayMs(10); P2=0xFF;

} } void Key_Scan(void) { unsigned int i = 0; P2 = 0x0F; while(P2 == 0x0F); if(P2 == 0x0E) R = 0; else if(P2 == 0x0D) R = 1; else if(P2 == 0x0B) R = 2; else if(P2 == 0x07) R = 3; P2 = 0xF0; while(P2 == 0xF0); if(P2 == 0xE0) C = 0; else if(P2 == 0xD0) C = 1; else if(P2 == 0xB0) C = 2; else if(P2 == 0x70) C = 3; DelayMs(20); } void lcd_cmd(unsigned char cmnd) { DATA = cmnd; RS = 0; RW = 0; lcd_e = 1; DelayMs(15); lcd_e = 0; } void lcd_display(unsigned char dat) { DATA = dat; RS = 1; RW = 0;

lcd_e = 1; DelayMs(15); lcd_e = 0; } void lcd_init(void) { unsigned char i; lcd_cmd(0x38); DelayMs(15); lcd_cmd(0x0c); DelayMs(15); lcd_cmd(0x06); DelayMs(15); lcd_cmd(0x01); DelayMs(15); lcd_cmd(0x80); DelayMs(15); i=0; while(msg[i]!='\0') { lcd_display(msg[i]); i++; } DelayMs(20); lcd_cmd(0xc0); i=0; while(msg1[i]!='\0') { lcd_display(msg1[i]); i++; } DelayMs(30); } void DelayMs(int k) { unsigned int a,b; for(a=0;a<=k;a++) for(b=0;b<1275;b++); }

Output:

Result: Thus the program to display value given at keypad interface and displayed on LCD panel.

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE:: Aim: Write a C program to read data from keypad interface and display on LCD using ARM processor. Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3,flashmagic Program: #include <LPC214x.h> #include <stdio.h> #include "Keypad.h" extern void Delay(void); unsigned char Row_Data, Col_Data; unsigned char Msg[4][4] = { '0','1','2','3', '4','5','6','7', '8','9','A','B', 'C','D','E','F'}; void Delay(void) { unsigned int i,j; for(i=0;i<35;i++) for(j=0;j<1234;j++); } void main(void) { U0LCR = 0x83; U0DLL = 0x61; U0LCR = 0x03; PINSEL0 |= 0x05; SCS |= 0x03; PINSEL2 |= 0x0; U0THR = 'A'; while (1) { Delay(); Date: ...........................

Delay(); KeyScan(&IOPIN1/*KeyPad Port*/,16/*Starting Data Pin D0*/, &Row_Data/*Addr of Row*/,&Col_Data/*Addr of Col*/); if (Row_Data < 4 && Col_Data < 4) { U0THR = Msg[Row_Data][Col_Data]; Delay(); Delay(); U0THR = '\n'; } } } Output:

Result: Thus the program to display value given at keypad interface and displayed on LCD panel.

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE: Aim: Write a C program to receive data serially. Equipment Required: Hardware: Personnel Computer,microcontroller kit Software: Keil Vision3, flashmagic Program: #define CR 0x0D #include <LPC21xx.H> void init_serial (void); int putchar (int ch); int getchar (void); unsigned char test; int main(void) { char *Ptr = "*** UART0 Demo ***\n\n\rType Characters to be echoed!!\n\n\r"; VPBDIV = 0x02; init_serial(); while(1) { while (*Ptr) { putchar(*Ptr++); } putchar(getchar()); } } Date: ...........................

void init_serial (void) { PINSEL0 = 0x00000005; U0LCR = 0x00000083; U0DLL = 0x000000C3; U0LCR = 0x00000003; } int putchar (int ch) { if (ch == '\n') { while (!(U0LSR & 0x20)); U0THR = CR; } while (!(U0LSR & 0x20)); return (U0THR = ch); } int getchar (void) { while (!(U0LSR & 0x01)); return (U0RBR); }

Output:

Result: Thus the program to receive data serially was executed successfully and got the desired output.

DEPARTMENT OF.................................................................................................................. ........................................................................................................................LABORATORY Expt. No: TITLE: Aim: Write a C program to send data serially through serial port using ARM processor. Date: ...........................

Equipment Required: Hardware: Personnel Computer, Microcontroller Kit Software: Keil Vision3, Flashmagic Program: #pragma INTERWORK #include <LPC21xx.H> #define CR 0x0D void init_serial (void) { PINSEL0 = 0x00050000; U1LCR = 0x83; U1DLL = 97; U1LCR = 0x03; } int putchar (int ch) {

if (ch == '\n') { while (!(U1LSR & 0x20)); U1THR = CR; } while (!(U1LSR & 0x20)); return (U1THR = ch); } int getchar (void) { while (!(U1LSR & 0x01)); return (U1RBR); }

Output:

Result:

Thus the program to send data serially through serial port was executed successfully and got the desired output.

You might also like