Contador Utilizando Memoria Eeprom 24C256 PDF

Title Contador Utilizando Memoria Eeprom 24C256
Author Dan Roque
Course Brand
Institution Instituto Tecnológico de Los Mochis
Pages 3
File Size 142.2 KB
File Type PDF
Total Downloads 72
Total Views 134

Summary

Programación de microcontrolador...


Description

D.R.L.

CONTADOR UTILIZANDO MEMORIA EEPROM 24C256

CÓDIGO FUENTE DEL PROGRAMA DE PRUEBA. 'Contador que se incrementa y decrementa mediante pulsadores, 'se muestra el valor en un LCD y se almacena en una memoria EEPROM AllDigital TRISA = 0xff TRISB = 0 TRISD = 0 TRISE = %00000111 TRISC = %11110000 'TRISC = 0 Define LCD_BITS = 8 Define LCD_DREG = PORTB Define LCD_DBIT = 0 Define LCD_RSREG = PORTC Define LCD_RSBIT = 0 Define LCD_RWREG = PORTC Define LCD_RWBIT = 1 Define LCD_EREG = PORTC Define LCD_EBIT = 2 Define LCD_COMMANDUS = 2000 Define LCD_DATAUS = 50 Define LCD_INITMS = 2 Lcdinit

D.R.L.

Symbol scl = PORTC.3 Symbol sda = PORTC.4 WaitMs 100 Dim cont As Word Dim b_alto As Byte Dim b_bajo As Byte Dim aux As Word Dim control As Bit control = 0 Dim control2 As Bit control2 = 0 Dim control3 As Bit control3 = 0 Dim dir1 As Word dir1 = 10 Dim dir2 As Word dir2 = 11 I2CRead sda, scl, 0xa0, dir1, b_alto WaitMs 10 I2CRead sda, scl, 0xa0, dir2, b_bajo cont = b_alto * 256 + b_bajo inicio: Gosub increm_decrem Gosub mostrar Gosub borrar Goto inicio End increm_decrem: If PORTE.0 = True Then If control = 0 Then cont = cont + 1 b_bajo = cont Mod 256 aux = cont - b_bajo b_alto = aux / 256 I2CWrite sda, scl, 0xa0, dir1, b_alto WaitMs 10 I2CWrite sda, scl, 0xa0, dir2, b_bajo control = 1 Endif Else control = 0 Endif

D.R.L.

If PORTE.1 = True Then If control2 = 0 Then If cont > 0 Then cont = cont - 1 b_bajo = cont Mod 256 aux = cont - b_bajo b_alto = aux / 256 I2CWrite sda, scl, 0xa0, dir1, b_alto WaitMs 10 I2CWrite sda, scl, 0xa0, dir2, b_bajo control2 = 1 Endif Endif Else control2 = 0 Endif Return mostrar: Lcdcmdout LcdClear Lcdout "Contador" Lcdcmdout LcdLine2Home Lcdout #cont WaitMs 2 Return borrar: If PORTE.2 = True Then If control3 = 0 Then cont = 0 b_bajo = cont Mod 256 aux = cont - b_bajo b_alto = aux / 256 I2CWrite sda, scl, 0xa0, dir1, b_alto WaitMs 10 I2CWrite sda, scl, 0xa0, dir2, b_bajo control3 = 1 Endif Else control3 = 0 Endif Return...


Similar Free PDFs