Documentos de Académico
Documentos de Profesional
Documentos de Cultura
FACULTAD DE INGENIERIAS
SISTEMAS MICROPORCESADOS I
CARLOS OCAMPO
FERNANDO ITAS
OSCAR AYALA
ANDRES VALDIVIESO
2 010 – 06 - 15
EJERCICIO 1
Diseñar un programa para calcular los valores para la función y=1 – cos(x) – exp(x), los valores
serán ingresados mediante el teclado en un rango entre 0 y 9 y el valor resultante se observara
en la segunda línea del LCD.
program ejercicio_1
dim a as byte
dim op as string[6]
dim sr as String[17]
dim b as string[6]
lcd_out(1,1,"valor 1:")
n1=keypad_released
intTostr(n1,sn1)
lcd_out(1,10,sn1)
delay_ms(1000)
end sub
lcd_cmd(lcd_clear)
lcd_out(1,1,"1")
lcd_out_cp(op)
lcd_out_cp("cos(x)")
lcd_out_cp(op)
lcd_out_cp("exp(x)")
lcd_out_cp("=")
FloatToStr(resf,sr)
lcd_out(2,1,sr)
delay_ms(1500)
lcd_cmd(lcd_clear)
end sub
lcd_cmd(lcd_clear)
leer
op="-"
m1=cos(n1)
m2=exp(n1)
resultado=m1-m2
displayresf
end sub
main:
lcd_config(portb,7,6,5,4,portb,0,1,2)
lcd_cmd(lcd_cursor_off)
keypad_init(portc)
lazo:
while (a=0)
lcd_out(1,1,"Ingrese su")
lcd_out(2,1,"valor de x: ")
a=keypad_released
wordtostr(a,b)
wend
lcd_out(2,8,b)
delay_ms(500)
operaciones
n1=0
a=0
goto lazo
end.
LCD1
LM016L
RV1
VDD
VSS
VEE
RW
RS
D0
D1
D2
D3
D4
D5
D6
D7
E
C2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1k
22p
X1 U1
CRYSTAL 13 33
C1 14
OSC1/CLKIN RB0/INT
34
OSC2/CLKOUT RB1
35
RB2
2 36
RA0/AN0 RB3/PGM
22p 3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
R1 RA5/AN4/SS/C2OUT
15
10k RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
1
MCLR/Vpp/THV
RC4/SDI/SDA
RC5/SDO
23
24
A 7 8 9
25
RC6/TX/CK
26
RC7/RX/DT
RD0/PSP0
19
B 4 5 6
20
RD1/PSP1
21
RD2/PSP2
RD3/PSP3
RD4/PSP4
22
27
C 1 2 3
28
RD5/PSP5
29
+
RD6/PSP6 ON
RD7/PSP7
30
D
C 0 =
PIC16F877A
4
9
8
7
6
5
4
3
2
RP1
RESPACK-8
EJERCICIO 3
Diseñar un programa para que al presionar un pulsante 8 veces se incremente en una pareja de
display de 7 segmentos los nueros de 4 en 4 comenzando en 1. Sino se presiona el pulsante se
debe observar el valor ultimo
program ejercicio_3
main:
TRISC=0
TRISD=0
TRISA=$FF
Option_reg=%10100010
intcon=$0
tmr0=0
LAZO:
if TMR0=0 then
portd=%00111111 '0
portc=%00000110 '4
else
if TMR0=1 then
portd=%00111111 '0
portc=%01111111 '8
else
if TMR0=2 then
portd=%00000110 '1
portc=%01011011 '2
else
if TMR0=3 then
portd=%00000110 '1
portc=%01111101 '6
else
if TMR0=4 then
portd=%01011011 '2
portc=%00000110 '4
else
if TMR0=5 then
portd=%01011011 '2
portc=%01111111 '8
else
if TMR0=6 then
portd=%01001111 '3
portc=%01011011 '2
else
if TMR0=7 then
portd=%01001111 '3
portc=%01111101 '6
else
if TMR0=8 then
portd=%00000110 '4
portc=%00111111 '0
else
if TMR0=9 then
portd=%00000110 '4
portc=%00000110 '4
if TMR0=9 then
portd=%00000110 '4
portc=%01111111 '8
if TMR0=9 then
portd=%01101101 '5
portc=%01011011 '2
if TMR0=9 then
portd=%01101101 '5
portc=%01111101 '6
if TMR0=9 then
portd=%01111101 '6
portc=%00111111 '0
if TMR0=9 then
portd=%01111101 '6
portc=%00000110 '4
if TMR0=9 then
portd=%01111101 '6
portc=%01111111 '8
if TMR0=9 then
portd=%00000111 '7
portc=%01011011 '2
if TMR0=9 then
portd=%00000111 '7
portc=%01111101 '6
if TMR0=9 then
portd=%01111111 '8
portc=%00000110 '4
if TMR0=9 then
portd=%01111111 '8
portc=%01111111 '8
if TMR0=9 then
portd=%01100111 '9
portc=%01011011 '2
if TMR0=9 then
portd=%01100111 '9
portc=%01111101 '6
ELSE
RETURN
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
GOTO LAZO
end.
C1
1uF
X1
CRYSTAL
U1
13 33
C2 14
OSC1/CLKIN RB0/INT
34
OSC2/CLKOUT RB1
35
RB2
2 36
RA0/AN0 RB3/PGM
1uF 3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
R1 RC6/TX/CK
25
10k 26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
27
RD4/PSP4
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7
PIC16F877A
Có digo:
program ejer4
trisc=0
trisd=0
trisb=$FF
option_reg=%10000000
intcon=%10010000
a=0
b=0
lcd_config(portc,7,6,5,4,portc,0,1,2)
lcd_cmd(lcd_cursor_off)
end sub
portd.0=1
delay_ms(2000)
portd.1=0
delay_ms(1000)
intcon.intf=0
a=a+1
end sub
main:
init
LOOP:
bytetostr(a,valor)
lcd_cmd(lcd_clear)
lcd_out(1,1,valor)
delay_ms(500)
goto LOOP
end.
Có digo:
program ejer5
dim L as byte
trisc=0
trisd=0
trisb=$FF
option_reg=%10000000
intcon=%10010000
L=0
a=0
b=0
portd=0
lcd_config(portc,7,6,5,4,portc,0,1,2)
lcd_cmd(lcd_cursor_off)
end sub
portd.0=1
delay_ms(2000)
portd.0=0
delay_ms(1000)
intcon.intf=0
end sub
main:
init
LOOP:
lcd_cmd(lcd_clear)
lcd_out(1,1,"UNIVERSIDAD POLI")
lcd_out(2,1,"TECNICA SALESIANA")
delay_ms(1000)
goto LOOP
end.