100% found this document useful (1 vote)
84 views

Universidad Tecnologica de Santiago Utesa: Asignatura Microprocesador II

This document contains a student's submission for an assignment on generating square waves using a microprocessor timer. It first calculates the parameters to generate a 50kHz square wave using Timer 0 in modes 0, 1 and 2. It then does similar calculations to generate a 0.5 second delay using Timer 0. Code examples are provided for each case.

Uploaded by

Bond James
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
84 views

Universidad Tecnologica de Santiago Utesa: Asignatura Microprocesador II

This document contains a student's submission for an assignment on generating square waves using a microprocessor timer. It first calculates the parameters to generate a 50kHz square wave using Timer 0 in modes 0, 1 and 2. It then does similar calculations to generate a 0.5 second delay using Timer 0. Code examples are provided for each case.

Uploaded by

Bond James
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

UNIVERSIDAD TECNOLOGICA DE SANTIAGO

UTESA

ASIGNATURA
Microprocesador II

TEMA
Tarea segundo parcial

PRESENTADO POR:
SCHNEIDER FERJUSTE

MATRICULA:
1-17-2646

PROFESOR:
ING. RAUL TORIBIO

SANTIAGO DE LOS CABALLEROS,


REPUBLICA DOMINICANA
Diseñe un programa que genera una onda cuadrada en P0.0 de Fosc = 50khz.

Buscamos el periodo de onda:


T(on + off) = 1/50khz = 20uS
Ton/Toff = 20uS/2 = 10uS
Al aplicar la regla de tres para buscar el número de ciclo, tenemos:
X = (10uS * 1 c.m)/1uS = 10 ciclo.maquina
Modo 0: TH0.TL0 = 2X.2X
TL0 = 32 – 10 = 22

#include <REG51.H>

sbit led = P0^0;


void main(void)
{
TMOD = 0x00;
TCON = 0X00;
while(1)
{
TH0 = 255;
TL0 = 255;
TR0 = 1;
while(TF0 != 1);
TF0 = 0;
TR0 = 0;
led =~led; }
}
MODO 1:

#include <REG51.H>

sbit led = P0^0;


void main(void)
{
TMOD = 0x01;
TCON = 0X00;
while(1)
{
TH0 = 1;
TL0 = 0;
TR0 = 1;
while(TF0 != 1);
TF0 = 0;
TR0 = 0;
led =~led; }
}

MODO 2:

#include <REG51.H>

sbit led = P0^0;


void main(void)
{
TMOD = 0x00;
TCON = 0X00;
while(1)
{
TH0 = 255;
TL0 = 254;
TR0 = 1;
while(TF0 != 1);
TF0 = 0;
TR0 = 0;
led =~led; }
}

Diseñe un programa (Timer1) que genere un delay de 0.5seg  (LED ON/OFF)

Buscamos el periodo de onda:


T(on + off) = 0.5s
Ton/Toff = 0.5s/2 = 0.25s
Al aplicar la regla de tres para buscar el número de ciclo, tenemos:
X = (0.25s * 1 c.m)/1s = 0.25 ciclo.maquina
Modo 0: TH0.TL0 = 2X.2X
TL0 = 32 – 0.25 = 31.75

#include <REG51.H>

sbit led = P0^0;


void main(void)
{
TMOD = 0x00;
TCON = 0X00;
while(1)
{
TH0 = 255;
TL0 = 255;
TR0 = 1;
while(TF0 != 1);
TF0 = 0;
TR0 = 0;
led =~led; }
}
MODO 1:

#include <REG51.H>

sbit led = P0^0;


void main(void)
{
TMOD = 0x01;
TCON = 0X00;
while(1)
{
TH0 = 1;
TL0 = 0;
TR0 = 1;
while(TF0 != 1);
TF0 = 0;
TR0 = 0;
led =~led; }
}

MODO 2:

#include <REG51.H>

sbit led = P0^0;


void main(void)
{
TMOD = 0x00;
TCON = 0X00;
while(1)
{
TH0 = 255;
TL0 = 254;
TR0 = 1;
while(TF0 != 1);
TF0 = 0;
TR0 = 0;
led =~led; }
}

You might also like