Professional Documents
Culture Documents
Practica Nº11 Laboratorio de Microcontroladores 2020-2
Practica Nº11 Laboratorio de Microcontroladores 2020-2
LABORATORIO DE MICROCONTROLADORES
2020-2
ESTUDIANTE:
JOSÉ AGUILAR MALAVÉ
CURSO:
ELECTRONICA 8/1
DOCENTE:
ING. SENDEY VERA GONZALEZ
UPSE FACSISTEL
OBJETIVOS
DESARROLLO
Parte A Código
}
//-------------------- Formats date and time
void Transform_Time() {
seconds = ((seconds & 0xF0) >> 4)*10 + (seconds & 0x0F); //Transform seconds
minutes = ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F); //Transform months
hours = ((hours & 0xF0) >> 4)*10 + (hours & 0x0F); //Transform hours
year = (day & 0xC0) >> 6; //Transform year
day = ((day & 0x30) >> 4)*10 + (day & 0x0F); //Transform day
month = ((month & 0x10) >> 4)*10 + (month & 0x0F); //Transform month
}
//-------------------- Output values to LCD
void Display_Time() {
Lcd_Chr(1, 6, (day / 10) + 48); // Print tens digit of day variable
Lcd_Chr(1, 7, (day % 10) + 48); // Print oness digit of day variable
Lcd_Chr(1, 9, (month / 10) + 48);
Lcd_Chr(1,10, (month % 10) + 48);
Lcd_Chr(1,15, year + 48); // Print year variable (start from year 2010)
Lcd_Chr(2, 6, (hours / 10) + 48);
Lcd_Chr(2, 7, (hours % 10) + 48);
Lcd_Chr(2, 9, (minutes / 10) + 48);
Lcd_Chr(2,10, (minutes % 10) + 48);
Lcd_Chr(2,12, (seconds / 10) + 48);
Lcd_Chr(2,13, (seconds % 10) + 48);
}
//------------------ Performs project-wide init
void Init_Main() {
TRISB = 0;
PORTB = 0xFF;
TRISB = 0xff;
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
Codificación en Mikro C
Planteamiento del sistema electrónico
Funcionamiento
Diagrama de flujo
Parte B Código
main:
delay_ms(250)
while true
i=0
while Button(PORTE, 2, 1, 1) and Button(PORTB, 0, 1, 1)
UART1_Write_Text("memoria ") ' Enviamos el texto memoria
WordToStr( i, text)
UART1_Write_Text(text) ' Enviamos la localidad de memoria
UART1_Write_Text(" valor ") ' Enviamos el texto valor
WordToStr( leer_eeprom(hi(i), lo(i)), text)
UART1_Write_Text(text) ' Enviamos el valor de la localidad de memoria
UART1_Write(0x0D) ' Ascci del enter
delay_ms(75)
inc(i)
' if i=0x8000 then ' Recorremos hasta que el valor de la direccion de 32767
if i=0x0100 then ' Recorremos hasta que el valor de la direccion de 255
i=0 ' de memoria no supere los 0x8000
end if
wend
'' ESCRIBIR EN LA EEPROM
if Button(PORTE, 2, 1, 0) then
' for i=0 to 0x7FFF ' Recorremos todas las direcciones de memoria 32767
num_temp = 0
for i=0 to 0x00FF ' Recorremos todas las direcciones de memoria 255
escribe_eeprom(hi(i), lo(i), num_temp)
inc(num_temp) ' Incrementamos el valor a guardar en la memoria
PORTD = 0XFF ' Encendemos los leds indicando el trabajo
next i
PORTD = 0X00 ' Apagamos los leds indicando el terminado
end if
'' BORRAR LA EEPROM
if Button(PORTB, 0, 1, 0) then
' for i=0 to 0x7FFF ' Recorremos todas las direcciones de memoria 32767
for i=0 to 0x00FF ' Recorremos todas las direcciones de memoria 255
' por defecto el valor de la eeprom es 0xFF
escribe_eeprom(hi(i), lo(i), 0xFF)
PORTD = 0XFF ' Encendemos los leds indicando el trabajo
next i
PORTD = 0X00 ' Apagamos los leds indicando el terminado
end if
wend
end.
CONCLUSIONES