Escolar Documentos
Profissional Documentos
Cultura Documentos
Disciplina de Microcontroladores
Prof. Rubo
ESTRUTURA DE UM PROGRAMA EM C
#include <REG52.H>
main (void)
{
int a;
}
*/
ESCOLHA DA REGIO DE
ARMAZENAMENTO DE DADOS
ESCOLHA DA REGIO DE
ARMAZENAMENTO DE DADOS
ESCOLHA DA REGIO DE
ARMAZENAMENTO DE DADOS
TIPOS DE DADOS COMPOSTOS MATRIZES
#include <stdio.h>
void main (void)
{
char nome_da_variavel [2];
nome_da_variavel[0] = 12;
nome_da_variavel[1] = 13;
}
CONTROLADORES DE DECISO
void main( )
{
int a=3;
if (a= =10) {a=1}
else
{a=2};
}
int a,b;
a=3;
Switch (a)
{
case 0: b=10; break;
case 1: b=20; break;
case 3: b=40; break;
default: b=0; break;
}
CONTROLADORES DE LOOPING
void main()
{
int b, a;
for (a=0; a<0xff;
a++)
P1=a;
}
ATENDIMENTO S INTERRUPES
as interrupes so vetoradas
nmero das interrupes, segundo o compilador.
0 int0 0x0003
1 timer0 0x000B
.
.
.
4 serial 0x0023
5 timer2 0x002B
ATENDIMENTO S INTERRUPES
# include <reg52.h>
# include <stdio.h>
sbit P1_0=0x90;
sbit P1_1=0x91;
void int_0( ) interrupt 0
{
P1_1= ~P1_1;
}
void main()
{
EA=1;
EX0=1;
while(1)
{
P1_0= ~P1_0;
}
}
void main()
{ char vetor;
code char dados [4] = {0x01, 0x04,
0x07, 0x08};
P1=0;
while (1)
{for (vetor=0; vetor<4; vetor ++)
{P1=dados[vetor];
timer (2);//delay de 120
ms
}
}
}
void inicia_LCD()
{
int y;
P3_4=0;
// deixo o RS em zero
for(y=0; y<6; y++)
{(pulso (sequencia[y]));
P3_4=1;
// volto apenas pra
1
}}
void timer0 (unsigned char vezes)
{
TMOD=0x01;
while(vezes){
TH0=~(1000/256); //1ms
TL0=~(1000%256); //1ms
TR0=1;
while(!TF0);
vezes --; }}
PUBLIC ?C_STARTUP
CSEG AT
0000h ; alterar aqui!
?C_STARTUP: LJMP STARTUP1
BIBLIOGRAFIA