MCU 8051 IDE: Porovnání verzí

Z MediaWiki SPŠ a VOŠ Písek
Skočit na navigaci Skočit na vyhledávání
Bez shrnutí editace
Bez shrnutí editace
Řádek 23: Řádek 23:
== Simulace programu ==
== Simulace programu ==


== Ukázka příkladu ==
== Example ==
=== Porty - write ===
 
=== Write to Port ===


[[Soubor:RD2kit_08.jpg|400px]]
[[Soubor:RD2kit_08.jpg|400px]]
Řádek 55: Řádek 56:




=== Porty - Read/Write ===
=== Read from Ports ===


[[Soubor:RD2kit_09.jpg|400px]]
[[Soubor:RD2kit_09.jpg|400px]]
Řádek 68: Řádek 69:
</source>
</source>


=== Běžící světlo ===
=== Runing Light ===


[[Soubor:MCU-8051-IDE_03.jpg|400px]]
[[Soubor:MCU-8051-IDE_03.jpg|400px]]
Řádek 93: Řádek 94:
end
end
</source>
</source>
=== 7 segment ===
[[Soubor:MCU-8051-IDE_04.jpg|400px]]
<source lang="asm">
ORG  00H
ljmp MAIN
ORG 0030H
MAIN: mov SP,#7H
mov R2,#0 ;Set the initial value of R2, 0, R2 to display the value stored in
mov R5,#16
START: djnz R5,NEXT
mov R5,#16
mov R2,#0
NEXT: mov DPTR,#TAB
mov A,R2
movc A,@A+DPTR
mov P3,A
inc R2
lcall DELAY
jmp START
DELAY: mov R0,#1
DELAY0: mov R7,#1
DELAY1: mov R6,#1
djnz R6,$
djnz R7,DELAY1
djnz R0,DELAY0
ret
TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H ;0,1,2,3,4,5,6,7,8,9,
DB 08H,03H,46H,21H,06H,0EH ;A,B,C,D,E,F
END
</source>
=== 7 segment - C ===
[[Soubor:MCU-8051-IDE_05.jpg|400px]]
<source lang="CPP">
#include <reg51.h>
#include <at89x51.h>
#include <stdio.h>
#define DELAYTIME  65000 //Defined delay time constant
unsigned int temp1;
void delay(unsigned int temp)//Delay process
{
  while(--temp);
}
void main()
{
        P2=255;//led is off
        while(1)
{
            P2=0Xc0;//Display 0,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0XF9;//Display 1,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0XA4;//Display 2,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0XB0;//Display 3,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X99;//Display 4,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X92;//Display 5,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X82;//Display 6,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0Xf8;//Display 7,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X80;//Display 8,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X90;//Display 9,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X08;//Display A,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X03;//Display B,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X46;//Display C,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X21;//Display D,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X06;//Display E,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
P2=0X0E;//Display F,P2 port output of their section of the election code
temp1=DELAYTIME;
delay(temp1);
temp1=DELAYTIME;
delay(temp1);
}
}
</source>


== www ==
== www ==

Verze z 10. 6. 2012, 09:19

MCU 8051 IDE
popis: Vývoj aplikace pro 8051 v asm nebo C
vývojář Martin Ošmera
aktuální verze 1.4 (2011)
OS Unix-like, Microsoft Windows, freeBSD
typ softwaru aplikační
licence GNU General Public License
web mcu8051ide.sf.net wiki

Download Download

Instalace programu

Založení nového projektu

Simulace programu

Example

Write to Port

 	org 0 ;pseudoinstrukce umistujici program do pameti programu pocitace adresou 000h

start:  	
	mov A,#01010101b
	mov P3,A
	acall delay

	mov A,#10101010b
	mov P3,A
	acall delay

	sjmp start

delay:	mov R0,#01h
skok1:	mov R1,#01h
skok2:	mov R2,#01h
	
skok:	DJNZ	R2,skok
	DJNZ	R1,skok2
	DJNZ	R0,skok1

	ret
	end


Read from Ports

 	org 0 ;pseudoinstrukce umistujici program do pameti programu pocitace adresou 000h

start:  	
	mov A,#P1
	mov P3,A
	sjmp start

Runing Light

	org 0 ;pseudoinstrukce umistujici program od 00h

  	mov P3,#11111110B	;0. bit na log "0"
loop:	mov A,P3
	rlc A	 		;posun obsah A přes C doleva
	mov P3,A
	acall delay	 	;zavolá podprogram pro zpoždění 1s
 	sjmp loop	 	;skočí zpět k rotaci P1
 	  	  
delay:	mov R0,#01h		;podprogram zpoždění
skok1:	mov R1,#01h
skok2:	mov R2,#01h
 
skok:	djnz	R2,skok
	djnz	R1,skok2
	djnz	R0,skok1
 
	ret 	 
	end


7 segment

	ORG  00H

	ljmp MAIN

	ORG 0030H
MAIN:	mov SP,#7H
	mov R2,#0	;Set the initial value of R2, 0, R2 to display the value stored in
	mov R5,#16
START:	djnz R5,NEXT
	mov R5,#16
	mov R2,#0
NEXT:	mov DPTR,#TAB
	mov A,R2
	movc A,@A+DPTR
	mov P3,A
	inc R2
	lcall DELAY
	jmp START

DELAY:	mov R0,#1
DELAY0:	mov R7,#1
DELAY1:	mov R6,#1
	djnz R6,$
	djnz R7,DELAY1
	djnz R0,DELAY0
	ret
TAB:	DB	0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H ;0,1,2,3,4,5,6,7,8,9,
	DB	08H,03H,46H,21H,06H,0EH			 ;A,B,C,D,E,F
	END

7 segment - C

Soubor:MCU-8051-IDE 05.jpg

#include <reg51.h>
#include <at89x51.h>
#include <stdio.h>

#define DELAYTIME   65000 //Defined delay time constant
unsigned int temp1;

void delay(unsigned int temp)//Delay process
{
  while(--temp);
}

void main()
{

        P2=255;//led is off
        while(1)
		{
            P2=0Xc0;//Display 0,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0XF9;//Display 1,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0XA4;//Display 2,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0XB0;//Display 3,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X99;//Display 4,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X92;//Display 5,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X82;//Display 6,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0Xf8;//Display 7,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X80;//Display 8,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X90;//Display 9,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X08;//Display A,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X03;//Display B,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X46;//Display C,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X21;//Display D,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X06;//Display E,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);

			P2=0X0E;//Display F,P2 port output of their section of the election code
			temp1=DELAYTIME;
			delay(temp1);
			temp1=DELAYTIME;
			delay(temp1);

		
		}
}


www

8051

Soubor:MCU 8051 IDE.jpg