http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown
http://wwwispdowncom 51 C 51 isp 10 http://wwwispdowncom/showoneproductasp?productid=32 C http://wwwispdowncom/softviewasp?softid=196 PCB C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO ( ) C? KEIL KEIL51?! :P 1-1
http://wwwispdowncom 51 C : (1) Project New Project 1-2 Windows 1-3 N " " C "test" Windows " " uv2 KEILuVision2 (2) Ateml AT89C51 1-4 AT 8 9 C 5 1? (3) KEIL Demo C C 1-5 1 2 File-New Ctrl+N : #include<reg51h> void main(void) SCON = 0x50; // 1 TMOD = 0x20; // 1 2 TCON = 0x40; // 1 TH1 = 0xE8; //110592MHz 1200 TL1 = 0xE8; TI = 1; TR1 = 1; // while(1) printf ("Hello World!\n"); // Hello World
http://wwwispdowncom 51 C "Hello World!" (4) 1-5 3 File-Save Ctrl+S 1-3 test1c KEIL C 1-6 Source Group1 "Add File to Group 'Source Group 1'" ADD Source Group1 + (5)C HEX HEX 1-7 123 1 2 3 3 5 123 4
http://wwwispdowncom 51 C 6 \ Debug-Start\Stop Debug Session Ctrl+F5 (6) 1-8 1 2 3 4 5 51 4 "Hello World!"? C \ KEIL KEIL uvision2 C " PC C " C C PC C 51 51 MSC51 ATMEL AT89S51 isp isp AT89S51 P1 P15 MOSI P16 MISO P17 SCK
http://wwwispdowncom 51 C VCC GND RESET 10 10 S51 1 Vcc 40 GND 20 * 5V AT89LV51 27-6V 2 XTAL1 19
http://wwwispdowncom 51 C XTAL2 18 XTAL1 XTAL2 XTAL1 XTAL2 12MHz 6MHz 1MHz-24MHz 30PF * AT 8 9 C 5 1 12162024MHz AT89C51 24PC 24MHz40P6 3 RST 9 (24 ) 51 P0-P3 1 SFR ROM 00H 2-3 * RAM 4 (1) P0 [P00-P07] P0 8 I/O 1( 1) 8 TTL Flash ; P0 ( 8 )/ (2) P1 [P10-P17] P1 8 I/0 4 TTL 1 Flash 8 (3) P2 [P20-P27] P2 8 I/0 4 TTL 1 Flash 8 16 P2 8 8 (4) P3 [P30-P37] P2 8 I/0 4 TTL 1 Flash P3 2-2 *P1-3
http://wwwispdowncom 51 C!?? 47-10K Vcc GND 5 1 ALE/PROG 30 ALE( ) ALE ( 1/6) ALE Flash PROG 2 PSEN 29 AT89C51 2 3 EA/Vpp 31 AT89C51 ( 0000H-FFFFH) Flash Vpp Vpp 2-3 C KEIL uvision2 HEX HEX Intel 16 testuv2 3-1 1 Options for Target'Target1' Project Output 3-2 1 2 3 HEX HEX? HEX 3-3 ( : 3-1 1 Project
http://wwwispdowncom 51 C ) PC Windows 1200 "Hello World!" 3-4 AT89S51 LED LED 110592MHz 12MHz 1 VCC +5V 31 LED ( :http:/wwwispdowncom ) : #include<reg51h> //---------------------------------- void delay400ms(void) unsigned char TempCycA = 5; unsigned int TempCycB; while(tempcyca--) TempCycB=7269; while(tempcycb--);
http://wwwispdowncom 51 C ; //---------------------- main() while(1) P1=0xff; delay400ms(); delay400ms(); P1=0x00; delay400ms(); delay400ms(); KEIL C "//" "/*" "*/" C C main main main main LED LED ( IO 1 ) LED LED C C 1 "Timer1" "TIMER1" "1Timer" C51 32 :P KEIL uvision2 ANSI C 32 51 KEIL uvision2 C ( 1-1 1-2) 4-1 KEIL uvision2 C51 C charintshortlongfloat double C51 int short float double :
http://wwwispdowncom 51 C 1 char char unsigned char signed char signed char unsigned char 0 255signed char "0" "1" -128 +127unsigned char ASCII 255 * 1 2 int int int signed int unsigned int signed signed int -32768 +32767 "0" "1" unsigned int 0 65535 unsigned char unsigned int LED 3-4 D1 unsigned int D2 unsigned char : #include<reg51h> // void main(void) // unsigned int a; // a unsigned int unsigned char b; // b unsigned char do //do while for (a=0; a<65535; a++) P1^0 = 0; //65535 P10 LED P1^0 = 1; // P10 LED for (a=0; a<30000; a++); //
http://wwwispdowncom 51 C for (b=0; b<255; b++) P1^1 = 0; //255 P11 LED P1^1 = 1; // P11 LED for (a=0; a<30000; a++); // while(1); D1 D2 b 0 255 for (b=0; b<255; b++) for (b=0; b<256; b++) b 256 P1_1 = 1 a 0 65535 3 long long long signed long unsigned long signed long signed int -2147483648 +2147483647 "0" "1" unsigned long 0 4294967295 4float float 7 IEEE-754 5* C51 1 3 6 bit bit C51 0 1 Boolean True False 7 sfr sfr 0 255 51 sfr P1 = 0x90 P1 P1 P1 = 255( P1 ) *AT89C51 8sfr16 16 sfr16 0 65535sfr16 sfr T0 T1 9 sbit sbit C51 RAM sfr P1 = 0x90; // P1 sbit P1_1 = P1^1; //P1_1 P1 P11 // P11 sbit P1_1 = 0x91;
http://wwwispdowncom 51 C P1_1 P11 KEIL C51?! C51 1 1230-89 0x 0x34-0x3B L 104L034L0xF340 2 0888334534500 0 [±] [ ]e[±] [] 125e37e9-30e-3 3 'a''d' "\" 5-1 4 "test""ok" C \o "A" 'A' 5 #difine False 0x0; //
http://wwwispdowncom 51 C #difine True 0x1; // False 0True 1 // False 0 True 1 unsigned int code a=100; // code a const unsigned int c=100; // const c int a=110a++?! 6 LED P1 LED 3-4 LED : #include<reg51h> // P1 P1 void main(void) // cons tunsigned char design[32]=0xff0xfe0xfd0xfb0xf70xef0xdf0xbf0x7f 0x7F0xBF0xDF0xEF0xF70xFB0xFD0xFE0xFF 0xFF0xFE0xFC0xF80xF00xE00xC00x800x0 0xE70xDB0xBD0x7E0xFF; unsigned int a; // unsigned char b; // C51 // do for (b=0; b<32; b++) for(a=0; a<30000; a++); // P1 = design[b]; // P1 while(1); LED AT89S51 P1 P1 O LED P1 P1 P1 0xFE 11111110 D0 0 P10 LED1 a?? KEIL uvision2 IO Peripherals-I/O Ports-Port1 Port1 5-3 2 Port1 5-3 1 5-2 1 / / Breakpoints
http://wwwispdowncom 51 C "P1 = design[b];" Port1 5-2 2 Port1 Port1 P1 P1 P1 Pins 1 5-2 2 3 5-3 3 Watches design code D:0x08 4 Memory Address D:0x08 design uvision2 View 5-2 3
http://wwwispdowncom 51 C : [ ] [ ] : (auto) (extern) (static) (register) (auto) C51 6-1 KEIL uvision2 AT89C51 RAM 128 80H FFH 128 52 (SFR) AT89C51 SMALLCOMPACT LARGE 8051 SMALL 8051 SMALL data data ( ) COMPACT 8051 256 ( ) @R0/R1 LARGE 8051 64KB DPTR sfrsfr16sbit sfr sfr16 51 : sfr = ; sfr16 = ; AT89C51 P1 sfr P1 = 0x90; // P1 I/O 90H sfr P1 P1
http://wwwispdowncom 51 C (80H-FFH) sfr 8 sfr16 16 8052 T2 : sfr16 T2 = 0xCC; // 8052 2 T2L=CCHT2H=CDH sfr16 16 0 1 sbit P1 2 P11 : (1) sbit = sbit P1_1 = Ox91; sfr sbit 80H-FFH (2) sbit = ^ sft P1 = 0x90; sbit P1_1 = P1 ^ 1; // (3) sbit = ^ sbit P1_1 = 0x90 ^ 1; 2 C51 bdata bdata : unsigned char bdata ib; // ucsigned char ib int bdata ab[2]; // ab[2] sbit ib7=ib^7 // sbit sbit ab12=ab[1]^12; "^" char0-7int0-15long0-31 LED : sfr P1 = 0x90; // sbit P1_0 = P1 ^ 0; // sbit P1_7 = 0x90 ^ 7; // sbit P1_1 = 0x91; // P1 P10P11P17 void main(void) unsigned int a; unsigned char b; do for (a=0;a<50000;a++) P1_0 = 0; // P1_0 for (a=0;a<50000;a++) P1_7 = 0; // P1_7 for (b=0;b<255;b++)
http://wwwispdowncom 51 C for (a=0;a<10000;a++) P1 = b; // b P1 = 255; // P1 LED for (b=0;b<255;b++) for (a=0;a<10000;a++) //P1_1 P1_1 = 0; for (a=0;a<10000;a++) P1_1 = 1; while(1);