8051 smd kit_manual

1,504 views

Published on

Published in: Education
  • Be the first to comment

8051 smd kit_manual

  1. 1. User’s Manual for 8051 Development Kit 8051SM-10x15 Developed at S.R.K.N.E.C. M.Tech. VLSI Lab By: Anish Goel Assist. Prof. Electronics Dept. (M.S.E.E., NJIT, USA)
  2. 2. CONTENTS 1. Introduction 2. Details of the development kit and features. 3. Connecting and powering up the kit. 4. Tutorial on RIDE and Flash Magic 5. Sample codes 8051SM-10x15 Manual Page 2
  3. 3. Chapter 1 Introduction This development kit is a high end 8051microcontroller development kit intended for advanced embedded applications. The kit is developed using surface mount technology, double sided PCB and uses surface mounting components. The development kit contains the following: 1. A 10cm x 15cm 8051 Development kit PCB with following devices on it: a. P89V51RD2FBC microcontroller chip. b. MAX232 chip c. DS 1307 RTC chip d. AT24C16 EEPROM chip e. ULN2803 chip f. SMD LED’s – 8 Nos. g. Pushbutton Switches – 6 Nos. h. Serial DB-9 Connector. i. 32.768 Khz crystal and 3V battery for RTC j. LM7805 voltage regulator IC and filtering capacitors. k. 11.0592 MHz crystal and other discrete components. 2. A serial Cable. 3. A CD containing the required software’s and this instruction manual. 4. 16x2 LCD module mounted on 16 pin FRC connector. 5. 5x2 FRC/ribbon cables – 4 Nos. 6. D.C. Adaptor 8051SM-10x15 Manual Page 3
  4. 4. Chapter 2 Details of the development kit and Features 10 1 11 2 12 3 13 4 14 15 2 2 12 5 16 6 17 7 18 8 19 9 20 8051SM-10x15 Manual Page 4
  5. 5. Identification 1 ------------------------------------------------------ Outputs of ULN2803 2 ------------------------------------------------------ LED’s 3 ------------------------------------------------------ ULN 2803 IC 4 ------------------------------------------------------ AT24C16 IC 5 ------------------------------------------------------ FRC connectors * 6 ------------------------------------------------------ DC Jack 7 ------------------------------------------------------ Capacitor and filter 8 ------------------------------------------------------Input Switches 9 ------------------------------------------------------ON/OFF Switch 10 ------------------------------------------------------LCD contrast control preset 11 ------------------------------------------------------ LCD connector 12 ------------------------------------------------------ Serial Port DB-9 Connector 13 ------------------------------------------------------MAX232 IC 14 ------------------------------------------------------DS1307 RTC IC 15 ------------------------------------------------------Crystal for RTC 16 ------------------------------------------------------Crystal for microcontroller 17 ------------------------------------------------------P89V51RD2 MuC 18 ------------------------------------------------------Expansion Slot 19 ------------------------------------------------------Battery back-up for RTC 20 ------------------------------------------------------Power ON LED * Refer to following sections for detailed configuration. 8051SM-10x15 Manual Page 5
  6. 6. Features: 1. The size of the kit is very small, due to SMD’s and double sided PCB and it is extremely handy and can be easily used without proper lab setup with a laptop machine. Size in cm: 10 x 15 2. CPU of the development kit P89V51RD2FBC which is a In-system programmable microcontroller with intel 8051 architecture. 3. For basic input/output interface LED’s and switches are provided. 4. The switches are provided as per configuration of a menu driven program. 5. ULN2803 IC provides up to 8 Darlington pairs that may be used for driving motors or relays. 6. A MAX-232 IC with capacitors is interfaced to the microcontroller at its SCI port to provide serial communication. 7. Power-ON reset circuitry is provided on the board that resets the microcontroller when it is powered up. A reset switch is also present to reset the microcontroller at any instance. 8. DC adaptor is provided to power up the kit. A ON/OFF switch is present to turn the kit ON/OFF. Power-ON indicator LED indicates if the kit is getting power. 9. A 11.0592 MHz crystal is present on the board to provide clock to the chip. 10.Male FRC connector pins are available on the kit as expansion slot to interface any other PCB or device to the microcontroller besides the ON- board interfaces. 11.LCD is interfaced in 4 bit mode and backlight of the LCD can be turned ON/OFF by software. Contrast control is provided using preset. 12. DS1307 Real time clock IC with crystal and battery back-up is available on- board to support real time applications. 13. AT24C16 EEPROM chip (2KB) is present on board to learn I2C interface and provide memory to the kit. 14. All ports of 8051 are available at the FRC male connectors of 5x2 configurations to make the connections flexible. Any of the on-board 8051SM-10x15 Manual Page 6
  7. 7. interfaces and devices may be connected to any of these ports using the FRC ribbon cables. Pin connections for MuC on the Kit. Pin Number Function Connected to: Comments 1 Port 1 5th Bit (P1.5) Port 1 Con. Pin 6 -- 2 Port 1 6st Bit (P1.6) Port 1 Con. Pin 7 -- 3 Port 1 7th Bit (P1.7) Port 1 Con. Pin 8 -- 4 Reset Reset Switch -- th 5 Port 3 0 Bit (P3.0)/RXD Port 3 Con. Pin 1 -- 6 NIC NC -- st 7 Port 3 1 Bit (P3.1)/TXD Port 3 Con. Pin 2 -- 8 Port 3 2nd Bit (P3.2) Port 3 Con. Pin 3 -- 9 Port 3 3rd Bit (P3.3) Port 3 Con. Pin 4 -- 10 Port 3 4th Bit (P3.4) Port 3 Con. Pin 5 -- 11 Port 3 5th Bit (P3.5) Port 3 Con. Pin 6 -- 12 Port 3 6th Bit (P3.6) Port 3 Con. Pin 7 -- 13 Port 3 7th Bit (P3.7) Port 3 Con. Pin 8 -- 14 XTAL1 Crystal -- 15 XTAL2 Crystal -- 16 VSS GND -- 17 NIC NC -- th 18 Port 2 0 Bit (P2.0 ) Port 2 Con. Pin 1 -- 19 Port 2 1st Bit (P2.1) Port 2 Con. Pin 2 -- 20 Port 2 2nd Bit (P2.2) Port 2 Con. Pin 3 -- 21 Port 2 3rd Bit (P2.3) Port 2 Con. Pin 4 -- 22 Port 2 4th Bit (P2.4) Port 2 Con. Pin 5 -- 23 Port 2 5th Bit (P2.5) Port 2 Con. Pin 6 -- 24 Port 2 6th Bit (P2.6) Port 2 Con. Pin 7 -- 25 Port 2 7th Bit (P2.7) Port 2 Con. Pin 8 -- 26 PSEN VCC -- 27 ALE NC -- 28 NIC NC -- 29 EA/Vpp VCC -- 30 Port 0 7th Bit (P0.7 ) Port 0 Con. Pin 8 -- 31 Port 0 6th Bit (P0.6) Port 0 Con. Pin 7 -- 32 Port 0 5th Bit (P0.5) Port 0 Con. Pin 6 -- 33 Port 0 4th Bit (P0.4) Port 0 Con. Pin 5 -- 34 Port 0 3rd Bit (P0.3) Port 0 Con. Pin 4 -- 8051SM-10x15 Manual Page 7
  8. 8. 35 Port 0 2nd Bit (P0.2) Port 0 Con. Pin 3 -- st 36 Port 0 1 Bit (P0.1) Port 0 Con. Pin 2 -- th 37 Port 0 0 Bit (P0.0) Port 0 Con. Pin 1 -- 38 VCC VCC -- 39 NIC NC -- 40 Port 1 0th Bit (P1.0) Port 1 Con. Pin 1 -- 41 Port 1 1st Bit (P1.1) Port 1 Con. Pin 2 -- nd 42 Port 1 2 Bit (P1.2) Port 1 Con. Pin 3 -- rd 43 Port 1 3 Bit (P1.3) Port 1 Con. Pin 4 -- th 44 Port 1 4 Bit (P1.4) Port 1 Con. Pin 5 -- * NIC: No internal Connection. ** NC: Not connected. Connection details from FRC connectors and Devices point of view ULN2803 PORT 0 Pin Config. of all FRC’s LED’s PORT 1 1 2 3 4 5 6 7 8 LCD PORT 3 9 10 Switch and I2C PORT 2 8051SM-10x15 Manual Page 8
  9. 9. Connection details: Component FRC’s Microcontroller FRC’s FRC Connector Connected FRC Connector Connected Connector Pin to Connector Pin to Name Name 1 ULN CH 8 1 P0.0 2 ULN CH 7 2 P0.1 3 ULN CH 6 3 P0.2 4 ULN CH 5 4 P0.3 ULN 5 ULN CH 4 Port 0 5 P0.4 2803 6 ULN CH 3 6 P0.5 7 ULN CH 2 7 P0.6 8 ULN CH 1 8 P0.7 9 NC 9 VCC 10 NC 10 GND 1 LED 1 1 P1.0 2 LED 2 2 P1.1 3 LED 3 3 P1.2 4 LED 4 4 P1.3 LED’s 5 LED 5 Port 1 5 P1.4 6 LED 6 6 P1.5 7 LED 7 7 P1.6 8 LED 8 8 P1.7 9 LED’s Cathode 9 VCC 10 NC 10 GND 1 RS 1 P3.0 2 RW 2 P3.1 3 EN 3 P3.2 4 LEC Backlight 4 P3.3 LCD 5 DB4 Port 3 5 P3.4 6 DB5 6 P3.5 7 DB6 7 P3.6 8 DB7 8 P3.7 9 VCC 9 VCC 10 GND 10 GND 1 UP(0) 1 P2.0 2 CANCEL(1) 2 P2.1 3 ENTER(2) 3 P2.2 4 DOWN(3) 4 P2.3 Switches 5 A(4) Port 2 5 P2.4 and 6 B(5) 6 P2.5 8051SM-10x15 Manual Page 9
  10. 10. I2C 7 SCL 7 P2.6 8 SDA 8 P2.7 9 VCC 9 VCC 10 GND 10 GND 8051SM-10x15 Manual Page 10
  11. 11. Chapter 3 Connecting and powering up the kit 1. Power is provided to the kit through DC adaptor provided with the kit. 2. Do not connect A.C. adaptor or DC adaptor with opposite polarity configuration pin. 3. Plug-in the adaptor in the A.C socket and insert the output pin of the adaptor into the D.C. jack present on the kit PCB. 4. After connecting the adaptor, push the ON/OFF switch. 5. The power LED on the kit turns ON to indicate that the kit is powered up properly. 6. The serial cable provided with the kit is used to transfer the hex code from the PC to the kit and also as a serial link between the kit and any other device while performing serial communication. 7. Connect one of the ends of the serial cable (Male connector) to the female serial DB-9 connector on the kit. 8. Connect the other end of this cable to the serial port of the computer (Desktop). 9. A USB to serial convertor may be used if the kit is to be connected to a Laptop. 10.There is no indication whether the serial link between the kit and computer is has been established. It is automatically verified once a program is transferred from the computer to the microcontroller successfully. 8051SM-10x15 Manual Page 11
  12. 12. Chapter 4 Tutorial on RIDE and Flash Magic Executing sample programs using RIDE. 1. Open the RIDE software. 2. To make a new project: • Project New • Specify a “Name”. • Directory where the project is to be stored. • Target family as 80C51. • Click “Next”. • Select the target device as: Atmel-AT89S52, or Philips- P89C/V51RD2xx. 8051SM-10x15 Manual Page 12
  13. 13. • Clock on “Finish” 3. The place on the left hand side is the project window. It shows all the details about the project. 4. To create new file: File New C File. 5. Write your code into the window on the right and save it. 6. Right click on your project name in the project window and click on “Add node source/application”. 7. Brows the saved C-File and click ok. This includes the C-File in the project. 8. To generate .HEX file of the project press F9. The hex file is generated is there are no errors in the code. 9. The location of the .HEX file is shown at the bottom of the RIDE window. 8051SM-10x15 Manual Page 13
  14. 14. 10. This file can be directly transferred to the microcontroller using Flash magic. Programming the microcontroller P89C/V51RD2BN using Philips Flash Magic 1. Open the Philips flash magic software. 2. Make the following setting in the software: • Select the appropriate COM port where the kit is connected. • Select the Baud rate (Generally keep it at 9600) • Select the device (89C51RD2xx or 89V51RD2) according to the microcontroller place on board. • Place a tick on “Erase all flash” 3. Brows your code’s .HEX File I the hex file space. 8051SM-10x15 Manual Page 14
  15. 15. 4. Click on the “Start” button. 5. The software gives a message “Reset the device in ISP mode now” (in case of 89V51RD2) 6. Turn the kit off by pressing the pushbutton switch (ON/OFF) switch and then switch it on. The above box disappears and the hex file gets transferred. 7. After the software shows “Finish” (bottom right of the window) Press “RESET” switch to execute your program. 8051SM-10x15 Manual Page 15
  16. 16. Chapter 5 Sample codes Code 1 This code will blink LED’s alternatively. Connect a FRC cable from the connector labeled “Port 1” to connector labeled “LED” /*Change the numbers 0xaa and 0x55 to change the pattern of the LED’s.*/ # include<reg51rx.h> main() { int t; P1=0xaa; for(t=0;t<50000;t++); P1=0x55; for(t=0;t<50000;t++); main(); } Code 2 This code checks if any of the switches at port 2 is pressed and then blinks the LED’s at port 1. Connect a FRC cable from the connector labeled “Port 1” to connector labeled “LED” Connect another FRC cable from connector labeled “Port 2” to connector labeled “I2C and Switches”. # include<reg51rx.h> void prog1(); void delay(); main() { int r; 8051SM-10x15 Manual Page 16
  17. 17. P2=0xff; if (P2!=0xff) { prog1(); } } void prog1(void) { P1=0x00; delay(); P1=0xff; delay(); main(); } void delay(void) { int t; for(t=0;t<50000;t++); } Code 3 Set the baud rate on hyper-terminal at 9600 bps /************************************************************/ /* this displays how to serially communicate without printf */ /************************************************************/ /* Change the matter in the statement “Hello World” to change the message. #include<reg51rx.h> void comsend(char *); void cominit(); void main() 8051SM-10x15 Manual Page 17
  18. 18. { cominit();//initialize UART for communication comsend("Hello World");//send the string while(1);//stop } void cominit() { TH1=-3;//timer 1 used as baud rate generator, gives 9600 baud TMOD=0x20;//timer 1 in mode 1 TR1=1;//start timer 1 SCON=0x50;//intialize UART } void comsend(char *dat)//read data { char data temp;//temporary for(temp=0;dat[temp];temp++)//count characters in the string { TI=0; SBUF=dat[temp];//transmit character while(!TI);//wait for transmission } } Code 4 This code will display a message on the LCD. Connect a FRC cable from the connector labeled “Port 2” to connector labeled “LCD” #include <reg51rx.h> //******************************************************** // DEFINE //********************************************************* // LCD 8051SM-10x15 Manual Page 18
  19. 19. #define LCD_RS 0x01 #define LCD_RW 0x02 #define LCD_E 0x04 #define LCD_BACKLIGHT 0x08 #define LCD_D4 0x10 #define LCD_D5 0x20 #define LCD_D6 0x40 #define LCD_D7 0x80 #define LCD_PORT P2 #define LCD_DATA 0x01 #define LCD_CTRL 0x00 #define LCD_C_BLINK_ON 0x09 #define LCD_C_BLINK_OFF 0xfe #define LCD_C_ON 0x0a #define LCD_C_OFF 0xfd #define LCD_DISPLAY_ON 0x0c #define LCD_DISPLAY_OFF 0xfb #define LCD_BACKLIGHT_ON 0x24 #define LCD_BACKLIGHT_OFF 0x25 //********************************************************** // PROTOTYPE //********************************************************** // LCD void LCDInit(unsigned char x,unsigned char y); void LCDOff(void); void LCDClrSCR(void); void LCDGotoXY(unsigned char,unsigned char); void LCDWriteString(char *); void LCDWriteConstString(const char *); void LCDWriteChar(char); void LCDWriteData(unsigned char,unsigned char); void LCDWait(void); void LCDDelay50us(int Delay); void LCDTextAttr(unsigned char attribute); void LCDContrast(unsigned char Cont); //*********************************************************** // GLOBAL VARIABLE //*********************************************************** // LCD unsigned char MaxX, MaxY, LCDStat; char Text[16]; //*********************************************************** // MAIN //*********************************************************** 8051SM-10x15 Manual Page 19
  20. 20. void main() { LCDInit(16,2); LCDClrSCR(); LCDGotoXY(1,1); LCDWriteConstString("Test Test Test Test0"); LCDGotoXY(1,2); LCDWriteConstString("--------------------0"); while(1); } //*********************************************************** // LCD Code /************************************************************ Name: void LCDClrSCR(void) Description: Clear the LCD **************************************************************/ void LCDClrSCR(void) { LCDWait(); LCDWriteData(LCD_CTRL,0x01); // Clear display } /************************************************************* Name: LCDGotoXY(unsigned char x, unsigned char y) Description: Position cursor on the LCD at X & Y location Input: X -> X position on the LCD Y -> Y position on the LCD **************************************************************/ void LCDGotoXY(unsigned char x,unsigned char y) { unsigned char address; x--; if (MaxY < 3) { switch(y) { case 'x01' : address = 0 + x; break; case 'x02' : address = 64 + x; break; } } 8051SM-10x15 Manual Page 20
  21. 21. else { switch(y) { case 'x01' : address = 0 + x; break; case 'x02' : address = 64 + x; break; case 'x03' : address = 20 + x; break; case 'x04' : address = 84 + x; break; } } LCDWriteData(LCD_CTRL,address | 0x80); } /*********************************************************** Name: WriteByteLCD(char byte) Description: Write a byte on the LCD at cursor position ************************************************************/ void LCDWriteChar(char byte) { char tmp; tmp = byte & 0xf0; tmp = tmp >> 4; tmp += 0x30; if (tmp > 0x39) tmp += 0x07; LCDWriteData(LCD_DATA,tmp); tmp = byte & 0x0f; tmp += 0x30; if (tmp > 0x39) tmp += 0x07; LCDWriteData(LCD_DATA,tmp); } /*********************************************************** Name: void LCDWriteString(char *ptr) Description: Write a string from RAM on the LCD Input: string pointer ************************************************************/ void LCDWriteString(char *ptr) { unsigned char i; 8051SM-10x15 Manual Page 21
  22. 22. for (i=1;i<41;i++) { if (*ptr == 0x00) break; LCDWriteData(LCD_DATA,*ptr++); } } /************************************************************ Name: void LCDWriteConstString(const char *ptr) Description: Write a constant string on the LCD Input: string pointer **************************************************************/ void LCDWriteConstString(const char *ptr) { unsigned char i; for (i=1;i<41;i++) { if (*ptr == 0x00) break; else if (i == 21) LCDGotoXY(1,2); LCDWriteData(LCD_DATA,*ptr++); } } /************************************************************** Name: void LCDWriteData(unsigned char rs, unsigned char ch) Description: Write a byte in rs of the LCD Input: rs -> Register select ch -> byte to write ***************************************************************/ void LCDWriteData(unsigned char rs,unsigned char ch) { unsigned char Stat; Stat = LCD_PORT & LCD_BACKLIGHT; LCD_PORT = Stat; LCDWait(); if ((ch & 0x80) == 0x80) LCD_PORT |= LCD_D7; if ((ch & 0x40) == 0x40) LCD_PORT |= LCD_D6; if ((ch & 0x20) == 0x20) LCD_PORT |= LCD_D5; if ((ch & 0x10) == 0x10) LCD_PORT |= LCD_D4; if (rs == 1) LCD_PORT |= LCD_RS; LCDDelay50us(1); LCD_PORT |= LCD_E; LCD_PORT &= ~LCD_E; LCD_PORT = Stat; if ((ch & 0x08) == 0x08) LCD_PORT |= LCD_D7; if ((ch & 0x04) == 0x04) LCD_PORT |= LCD_D6; 8051SM-10x15 Manual Page 22
  23. 23. if ((ch & 0x02) == 0x02) LCD_PORT |= LCD_D5; if ((ch & 0x01) == 0x01) LCD_PORT |= LCD_D4; if (rs == 1) LCD_PORT |= LCD_RS; LCDDelay50us(1); LCD_PORT |= LCD_E; LCD_PORT &= ~LCD_E; } /********************************************************** Name: void LCDWait(void) Description: wait for the LCD to be ready ***********************************************************/ void LCDWait(void) { int i,j; for (i=0;i<20;i++) { for (j=1;j<120;j++); } } /********************************************************* Name: void LCDDelay50us(int Delay) Description: Delay of 50 us with a 16Mhz resonator Input: Delay X x 50us **********************************************************/ void LCDDelay50us(int Delay) { int i,j; for (i=0;i<Delay;i++) { for (j=1;j<120;j++); } } /********************************************************** Name: void LCDTextAttr(unsigned char Attribute) Description: Set the LCD attribute Input: LCD_C_BLINK_ON : Cursor blink on LCD_C_BLINK_OFF : Cursor blink off LCD_C_ON : Cursor on LCD_C_OFF : Cursor off LCD_DISPLAY_ON : Display ON LCD_DISPLAY_OFF : Display OFF ************************************************************/ void LCDTextAttr(unsigned char attribute) { switch (attribute) { 8051SM-10x15 Manual Page 23
  24. 24. case LCD_C_BLINK_ON: LCDStat |= LCD_C_BLINK_ON; LCDWriteData(LCD_CTRL,LCDStat); break; case LCD_C_BLINK_OFF: LCDStat &= LCD_C_BLINK_OFF; LCDWriteData(LCD_CTRL,LCDStat); break; case LCD_C_ON: LCDStat |= LCD_C_ON; LCDWriteData(LCD_CTRL,LCDStat); break; case LCD_C_OFF: LCDStat &= LCD_C_OFF; LCDWriteData(LCD_CTRL,LCDStat); break; case LCD_DISPLAY_ON: LCDStat |= LCD_DISPLAY_ON; LCDWriteData(LCD_CTRL,LCDStat); break; case LCD_DISPLAY_OFF: LCDStat &= LCD_DISPLAY_OFF; LCDWriteData(LCD_CTRL,LCDStat); break; case LCD_BACKLIGHT_ON: LCD_PORT |= LCD_BACKLIGHT; break; case LCD_BACKLIGHT_OFF: LCD_PORT &= ~(LCD_BACKLIGHT); break; } } /************************************************************* Name: void LCDOn(unsigned char X, unsigned char Y) Description: Initialize LCD in 4bit mode Input: unsigned char X -> X size unsigned char Y -> Y size **************************************************************/ void LCDInit(unsigned char X, unsigned char Y) { MaxX = X; MaxY = Y; LCDStat = 0x0c; LCD_PORT = 0x00; LCD_PORT = ~(LCD_D7+LCD_D6+LCD_D5+LCD_D4+LCD_E+LCD_RS+LCD_RW); LCD_PORT |= LCD_BACKLIGHT; 8051SM-10x15 Manual Page 24
  25. 25. LCDDelay50us(340); LCD_PORT = (LCD_D5 + LCD_D4 + LCD_BACKLIGHT); LCD_PORT |= LCD_E; LCD_PORT &= ~LCD_E; LCDDelay50us(100); LCD_PORT |= LCD_E; LCD_PORT &= ~LCD_E; LCDDelay50us(100); LCD_PORT |= LCD_E; LCD_PORT &= ~LCD_E; LCDDelay50us(100); LCD_PORT = (LCD_D5 + LCD_BACKLIGHT); LCD_PORT |= LCD_E; LCD_PORT &= ~LCD_E; LCDDelay50us(100); if (Y == 1) LCDWriteData(LCD_CTRL,0x20); // 1 line else LCDWriteData(LCD_CTRL,0x28); // 2 line LCDWriteData(LCD_CTRL,0x0c); // Disp ON-Cur OFF-Blink OFF LCDWriteData(LCD_CTRL,0x01); // Clear display LCDDelay50us(50); LCDWriteData(LCD_CTRL,0x06); // Cursor INC Shift OFF } For more details visit: www.dicovermechatronics.blogspot.com Email: 2007.anish@gmail.com Cell: 09970825313 8051SM-10x15 Manual Page 25

×