FRDM-KL46Z_LCD_Test Versión Corregida y Aumentada. Soporte para Display LCD en Modo GPIO, I2C y SPI Correcciones a la Biblioteca TextLCD para completa funcionalidad
main.cpp@0:261e911dcf75, 2022-09-22 (annotated)
- Committer:
- Antulius
- Date:
- Thu Sep 22 05:12:45 2022 +0000
- Revision:
- 0:261e911dcf75
TextLCD Corregida y Aumentada
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Antulius | 0:261e911dcf75 | 1 | /* ########################################################################### |
Antulius | 0:261e911dcf75 | 2 | ** Archivo : main.c |
Antulius | 0:261e911dcf75 | 3 | ** Proyecto : FRDM-KL46Z_LCD_Test |
Antulius | 0:261e911dcf75 | 4 | ** Procesador : MKL46Z256VLL4 |
Antulius | 0:261e911dcf75 | 5 | ** Herramienta : Mbed |
Antulius | 0:261e911dcf75 | 6 | ** Version : Driver 01.01 |
Antulius | 0:261e911dcf75 | 7 | ** Compilador : GNU C Compiler |
Antulius | 0:261e911dcf75 | 8 | ** Fecha/Hora : 14-07-2015, 11:48, # CodeGen: 0 |
Antulius | 0:261e911dcf75 | 9 | ** Descripción : |
Antulius | 0:261e911dcf75 | 10 | ** Este proyecto prueba todas las configuraciones para operar un |
Antulius | 0:261e911dcf75 | 11 | ** display LCD alfanumérico en modo de 4 bits |
Antulius | 0:261e911dcf75 | 12 | ** - Utilizando los GPIO's |
Antulius | 0:261e911dcf75 | 13 | ** - Utilizando el SPI y el C.I. SN74HC595 o CD4094 |
Antulius | 0:261e911dcf75 | 14 | ** - Utilizando el I2C y el Modulo PCF8574 y PCF8574A |
Antulius | 0:261e911dcf75 | 15 | ** soporta las siguintes pantallas LCD alfanuméricas: |
Antulius | 0:261e911dcf75 | 16 | ** 1x8, 1x16, 2x16, 2x20, 4x16, 4x20 |
Antulius | 0:261e911dcf75 | 17 | ** Componentes : GPIO, Timer, SPI, I2C, TextLCD. |
Antulius | 0:261e911dcf75 | 18 | ** Configuraciones : TextLCD, TextLCD_SPI, TextLCD_I2C |
Antulius | 0:261e911dcf75 | 19 | ** Autores : |
Antulius | 0:261e911dcf75 | 20 | ** ATEAM Development Group: |
Antulius | 0:261e911dcf75 | 21 | ** - Antulio Morgado Valle |
Antulius | 0:261e911dcf75 | 22 | ** |
Antulius | 0:261e911dcf75 | 23 | ** Versión : Beta |
Antulius | 0:261e911dcf75 | 24 | ** Revisión : A |
Antulius | 0:261e911dcf75 | 25 | ** Release : 0 |
Antulius | 0:261e911dcf75 | 26 | ** Date : 20/10/2019 |
Antulius | 0:261e911dcf75 | 27 | ** Bugs & Fixes : |
Antulius | 0:261e911dcf75 | 28 | ** Added support for Led_RGB |
Antulius | 0:261e911dcf75 | 29 | ** 22/09/2018 |
Antulius | 0:261e911dcf75 | 30 | ** Added LCD Menu, Beta version (with bugs) |
Antulius | 0:261e911dcf75 | 31 | ** |
Antulius | 0:261e911dcf75 | 32 | ** El permiso se otorga por este medio, sin cargo, a cualquier persona que |
Antulius | 0:261e911dcf75 | 33 | ** obtenga una copia de este software y los archivos de documentación asociados |
Antulius | 0:261e911dcf75 | 34 | ** (el "Software"), para operar en el Software sin restricciones, incluidos, |
Antulius | 0:261e911dcf75 | 35 | ** entre otros, los derechos de uso, copia, modificación, fusión, publicación, |
Antulius | 0:261e911dcf75 | 36 | ** distribución, sublicencia y/o venta de copias de el Software, y para permitir |
Antulius | 0:261e911dcf75 | 37 | ** que las personas a quienes se suministra el Software lo hagan, sujeto a las |
Antulius | 0:261e911dcf75 | 38 | ** siguientes condiciones: |
Antulius | 0:261e911dcf75 | 39 | ** |
Antulius | 0:261e911dcf75 | 40 | ** El aviso de copyright anterior y este aviso de permiso se incluirán en todas |
Antulius | 0:261e911dcf75 | 41 | ** las copias o partes sustanciales del Software. |
Antulius | 0:261e911dcf75 | 42 | ** |
Antulius | 0:261e911dcf75 | 43 | ** EL SOFTWARE SE PROPORCIONA "TAL CUAL", SIN GARANTÍA DE NINGÚN TIPO, EXPRESO |
Antulius | 0:261e911dcf75 | 44 | ** O IMPLÍCITO, INCLUYENDO PERO NO LIMITADO A LAS GARANTÍAS DE COMERCIABILIDAD, |
Antulius | 0:261e911dcf75 | 45 | ** APTITUD PARA UN PROPÓSITO PARTICULAR Y NO INCUMPLIMIENTO. EN NINGÚN CASO, |
Antulius | 0:261e911dcf75 | 46 | ** LOS AUTORES O TITULARES DE DERECHOS DE AUTOR SERÁN RESPONSABLES POR CUALQUIER |
Antulius | 0:261e911dcf75 | 47 | ** RECLAMACIÓN, DAÑOS U OTRAS RESPONSABILIDADES, YA QUE SEA RESPONSABLE DE UN |
Antulius | 0:261e911dcf75 | 48 | ** CONTRATO, CORTE U OTRA MANERA, DERIVADOS DE, FUERA O EN CONEXIÓN CON |
Antulius | 0:261e911dcf75 | 49 | ** EL SOFTWARE O EL USO O OTRAS REPARACIONES EN EL SOFTWARE. |
Antulius | 0:261e911dcf75 | 50 | ** ###########################################################################*/ |
Antulius | 0:261e911dcf75 | 51 | /* |
Antulius | 0:261e911dcf75 | 52 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
Antulius | 0:261e911dcf75 | 53 | : Includes |
Antulius | 0:261e911dcf75 | 54 | :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: |
Antulius | 0:261e911dcf75 | 55 | */ |
Antulius | 0:261e911dcf75 | 56 | #include "mbed.h" |
Antulius | 0:261e911dcf75 | 57 | #include "TextLCD.h" |
Antulius | 0:261e911dcf75 | 58 | #include "I2C.h" |
Antulius | 0:261e911dcf75 | 59 | #include "SPI.h" |
Antulius | 0:261e911dcf75 | 60 | #include "Serial.h" |
Antulius | 0:261e911dcf75 | 61 | #include "stdio.h" |
Antulius | 0:261e911dcf75 | 62 | /* |
Antulius | 0:261e911dcf75 | 63 | :............................................................................... |
Antulius | 0:261e911dcf75 | 64 | : Definiciones |
Antulius | 0:261e911dcf75 | 65 | :............................................................................... |
Antulius | 0:261e911dcf75 | 66 | */ |
Antulius | 0:261e911dcf75 | 67 | #define ON 0 // Estado para boton presionado |
Antulius | 0:261e911dcf75 | 68 | #define OFF 1 // Estado para boton sin presionar |
Antulius | 0:261e911dcf75 | 69 | #define HOLD 2 // Estado para boton mantenido |
Antulius | 0:261e911dcf75 | 70 | #define RELEASE 3 // Estado para boton liberado |
Antulius | 0:261e911dcf75 | 71 | #define REPEAT 4 // Estado para boton repetido |
Antulius | 0:261e911dcf75 | 72 | #define FALSE 0 // Estado FALSO |
Antulius | 0:261e911dcf75 | 73 | #define TRUE 1 // Estado VERDADERO |
Antulius | 0:261e911dcf75 | 74 | #define HIGH 1 // Estado ALTO |
Antulius | 0:261e911dcf75 | 75 | #define LOW 0 // Estado BAJO |
Antulius | 0:261e911dcf75 | 76 | #define BUZZ_ON 0 // Estado para Buzzer Encendido |
Antulius | 0:261e911dcf75 | 77 | #define BUZZ_OFF 1 // Estado para Buzzer Apagado |
Antulius | 0:261e911dcf75 | 78 | #define LCD_INTERFACE 1 // Tipo Interfaz del LCD: 0=Normal, 1=I2C, 2=SPI |
Antulius | 0:261e911dcf75 | 79 | #define I2C_ADDRESS 0x7E // Dirección I2C para Interfaz al LCD: 0x7E, 0x4E |
Antulius | 0:261e911dcf75 | 80 | #define TICKER_RATE 1000 // Periodo de Interrupción (us) |
Antulius | 0:261e911dcf75 | 81 | #define BAUD_RATE 115200 // Velocidad de Transmisión (Bauds)) |
Antulius | 0:261e911dcf75 | 82 | // 300, 600, 1200, 2400, 4800, 9600, |
Antulius | 0:261e911dcf75 | 83 | // 14400, 19600, 28800, 38400, 57600 |
Antulius | 0:261e911dcf75 | 84 | // 115200, 230400 |
Antulius | 0:261e911dcf75 | 85 | /* |
Antulius | 0:261e911dcf75 | 86 | +------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 87 | | Configuración de Puertos |
Antulius | 0:261e911dcf75 | 88 | +------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 89 | */ |
Antulius | 0:261e911dcf75 | 90 | Ticker TimerInt; // Inicializa la Interrupción por Timer |
Antulius | 0:261e911dcf75 | 91 | DigitalOut led_monitor(LED2); // Inicializa el LED Monitor |
Antulius | 0:261e911dcf75 | 92 | PwmOut buzzer (PTE31); // Inicializa el PWM para el Buzzer |
Antulius | 0:261e911dcf75 | 93 | PwmOut backlight(PTA13); // Inicializa el LED Backlight del LCD (Externo) |
Antulius | 0:261e911dcf75 | 94 | AnalogIn light (PTB0); // Inicializa Canal Analógico para BackLight |
Antulius | 0:261e911dcf75 | 95 | /* |
Antulius | 0:261e911dcf75 | 96 | ** ------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 97 | ** Inicialización de los Pines de Funciones Especiales. |
Antulius | 0:261e911dcf75 | 98 | ** ------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 99 | */ |
Antulius | 0:261e911dcf75 | 100 | |
Antulius | 0:261e911dcf75 | 101 | /************************************************* |
Antulius | 0:261e911dcf75 | 102 | * Host PC Communication channels |
Antulius | 0:261e911dcf75 | 103 | **************************************************/ |
Antulius | 0:261e911dcf75 | 104 | Serial terminal(USBTX, USBRX); // Inicializa la Comunicación Serial a la PC |
Antulius | 0:261e911dcf75 | 105 | //Serial terminal(PTA2,PTA1); // Terminal Serial |
Antulius | 0:261e911dcf75 | 106 | //Serial terminal(PTE0, PTE1); // Tx, Rx Using MAX3232 or BlueTooth |
Antulius | 0:261e911dcf75 | 107 | |
Antulius | 0:261e911dcf75 | 108 | /************************************************* |
Antulius | 0:261e911dcf75 | 109 | * Bluetooth Communication support |
Antulius | 0:261e911dcf75 | 110 | ************************************************** |
Antulius | 0:261e911dcf75 | 111 | * Initialize the library with the numbers of the interface pins |
Antulius | 0:261e911dcf75 | 112 | * Board Freedom FRDM-KL46Z |
Antulius | 0:261e911dcf75 | 113 | * IDE Mbed On Line Compiler |
Antulius | 0:261e911dcf75 | 114 | ***************************************************/ |
Antulius | 0:261e911dcf75 | 115 | Serial bluetooth(PTE0, PTE1); // Tx, Rx |
Antulius | 0:261e911dcf75 | 116 | |
Antulius | 0:261e911dcf75 | 117 | /************************************************** |
Antulius | 0:261e911dcf75 | 118 | * Instantiation for creating a TextLCD interface |
Antulius | 0:261e911dcf75 | 119 | * for using control and functions over selected port |
Antulius | 0:261e911dcf75 | 120 | ***************************************************/ |
Antulius | 0:261e911dcf75 | 121 | // LCD instantiation |
Antulius | 0:261e911dcf75 | 122 | #if LCD_INTERFACE == 0 |
Antulius | 0:261e911dcf75 | 123 | /************************************************* |
Antulius | 0:261e911dcf75 | 124 | * GPIO Pin Port |
Antulius | 0:261e911dcf75 | 125 | ************************************************** |
Antulius | 0:261e911dcf75 | 126 | * Initialize the library with the numbers of the interface pins |
Antulius | 0:261e911dcf75 | 127 | * Board Freedom FRDM-KL46Z |
Antulius | 0:261e911dcf75 | 128 | * IDE Mbed On Line Compiler |
Antulius | 0:261e911dcf75 | 129 | * LCD GPIO |
Antulius | 0:261e911dcf75 | 130 | * Pin Board |
Antulius | 0:261e911dcf75 | 131 | * VSS 5V |
Antulius | 0:261e911dcf75 | 132 | * VDD GND |
Antulius | 0:261e911dcf75 | 133 | * VO POT 1K |
Antulius | 0:261e911dcf75 | 134 | * RS PTC6 |
Antulius | 0:261e911dcf75 | 135 | * RW GND |
Antulius | 0:261e911dcf75 | 136 | * E PTC7 |
Antulius | 0:261e911dcf75 | 137 | * D4 PTC8 |
Antulius | 0:261e911dcf75 | 138 | * D5 PTC9 |
Antulius | 0:261e911dcf75 | 139 | * D6 PTC10 |
Antulius | 0:261e911dcf75 | 140 | * D7 PTC11 |
Antulius | 0:261e911dcf75 | 141 | * BL+ PTA13 |
Antulius | 0:261e911dcf75 | 142 | * BL- GND |
Antulius | 0:261e911dcf75 | 143 | ***************************************************/ |
Antulius | 0:261e911dcf75 | 144 | TextLCD lcd(PTC6,PTC7, PTC8, PTC9, PTC10, PTC11, TextLCD::LCD16x2); // 4bit bus: rs, e, d4-d7 (lsb -> msb) |
Antulius | 0:261e911dcf75 | 145 | DigitalOut LE (PTC4); // Pin para Latch Enable (SN74HC573) |
Antulius | 0:261e911dcf75 | 146 | #endif |
Antulius | 0:261e911dcf75 | 147 | #if LCD_INTERFACE == 1 |
Antulius | 0:261e911dcf75 | 148 | /************************************************* |
Antulius | 0:261e911dcf75 | 149 | * I2C Communication |
Antulius | 0:261e911dcf75 | 150 | ************************************************** |
Antulius | 0:261e911dcf75 | 151 | * Initialize the library with the numbers of the interface pins |
Antulius | 0:261e911dcf75 | 152 | * Board Freedom FRDM-KL46Z |
Antulius | 0:261e911dcf75 | 153 | * IDE Mbed On Line Compiler |
Antulius | 0:261e911dcf75 | 154 | * LCD I2C PCF8574A |
Antulius | 0:261e911dcf75 | 155 | * Pin Board LCD |
Antulius | 0:261e911dcf75 | 156 | * I2C_SCL SCL (white) + resistance pull-up 4.7k |
Antulius | 0:261e911dcf75 | 157 | * I2C_SDA SDA (blue) + resistance pull-up 4.7k |
Antulius | 0:261e911dcf75 | 158 | * 5V 5V (red) |
Antulius | 0:261e911dcf75 | 159 | * GND GND (black) |
Antulius | 0:261e911dcf75 | 160 | ***************************************************/ |
Antulius | 0:261e911dcf75 | 161 | I2C i2c_lcd(PTC2,PTC1); // SDA, SCL |
Antulius | 0:261e911dcf75 | 162 | TextLCD_I2C lcd(&i2c_lcd, I2C_ADDRESS, TextLCD::LCD20x4); // Address 0x4E or 0x7E I2C bus, PCF8574A Arduino Shield, LCD Type |
Antulius | 0:261e911dcf75 | 163 | #endif |
Antulius | 0:261e911dcf75 | 164 | #if LCD_INTERFACE == 2 |
Antulius | 0:261e911dcf75 | 165 | /************************************************* |
Antulius | 0:261e911dcf75 | 166 | * SPI Communication |
Antulius | 0:261e911dcf75 | 167 | ************************************************** |
Antulius | 0:261e911dcf75 | 168 | * Initialize the library with the numbers of the interface pins |
Antulius | 0:261e911dcf75 | 169 | * Board Freedom FRDM-KL46Z |
Antulius | 0:261e911dcf75 | 170 | * IDE Mbed On Line Compiler |
Antulius | 0:261e911dcf75 | 171 | * LCD SPI SN74HC595 |
Antulius | 0:261e911dcf75 | 172 | * Pin Board LCD |
Antulius | 0:261e911dcf75 | 173 | * SPI_MOSI SER (white) |
Antulius | 0:261e911dcf75 | 174 | * SPI_MISO none (blue) |
Antulius | 0:261e911dcf75 | 175 | * SPI_CLK SRCLK |
Antulius | 0:261e911dcf75 | 176 | * SPI_PCS RCLK |
Antulius | 0:261e911dcf75 | 177 | * 5V 5V (red) |
Antulius | 0:261e911dcf75 | 178 | * GND GND (black) |
Antulius | 0:261e911dcf75 | 179 | ***************************************************/ |
Antulius | 0:261e911dcf75 | 180 | SPI spi_lcd(PTD6,PTD7,PTD5,PTD4); // MOSI, MISO, SCLK, SSEL |
Antulius | 0:261e911dcf75 | 181 | DigitalOut SSel(PTD4); // Inicializa el Pin de Seleccion de Esclavo SPI |
Antulius | 0:261e911dcf75 | 182 | TextLCD_SPI lcd(&spi_lcd, PTD4, TextLCD::LCD20x4, TextLCD::HD44780); // SPI bus, SN74595 expander, CS pin, LCD Type |
Antulius | 0:261e911dcf75 | 183 | #endif |
Antulius | 0:261e911dcf75 | 184 | |
Antulius | 0:261e911dcf75 | 185 | /* |
Antulius | 0:261e911dcf75 | 186 | ** =================================================================== |
Antulius | 0:261e911dcf75 | 187 | ** Variables Globales del Programa |
Antulius | 0:261e911dcf75 | 188 | ** =================================================================== |
Antulius | 0:261e911dcf75 | 189 | */ |
Antulius | 0:261e911dcf75 | 190 | uint16_t Rate=TICKER_RATE/2; // Velocidad de barrido (500us = 0.5ms) |
Antulius | 0:261e911dcf75 | 191 | uint16_t counter=250; // Cuenta inicial de 250us |
Antulius | 0:261e911dcf75 | 192 | uint16_t heartbeat; // Contador de Overrunig |
Antulius | 0:261e911dcf75 | 193 | /* |
Antulius | 0:261e911dcf75 | 194 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Antulius | 0:261e911dcf75 | 195 | | Definición de Funciones Prototipo y Rutinas de los Vectores de Interrupción |
Antulius | 0:261e911dcf75 | 196 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
Antulius | 0:261e911dcf75 | 197 | */ |
Antulius | 0:261e911dcf75 | 198 | void Setup(void); // Rutina de Inicialización para el Hardware |
Antulius | 0:261e911dcf75 | 199 | void Caratula(void); // Carátula de Bienvenida |
Antulius | 0:261e911dcf75 | 200 | void Ticker_OnInterrupt(void); // Rutina de Atención para el Ticker |
Antulius | 0:261e911dcf75 | 201 | void Buzzer_Beep(void); // Pitidos del Buzzer |
Antulius | 0:261e911dcf75 | 202 | void I2C_Scanner(void); // Busca dispositivos conectados al bus I2C |
Antulius | 0:261e911dcf75 | 203 | void Test_LCD(void); // Prueba la operación del LCD |
Antulius | 0:261e911dcf75 | 204 | void Blinking_Led(void); // Rutina de Parpadeo del Led monitor |
Antulius | 0:261e911dcf75 | 205 | /* END definitions */ |
Antulius | 0:261e911dcf75 | 206 | /* |
Antulius | 0:261e911dcf75 | 207 | #=============================================================================== |
Antulius | 0:261e911dcf75 | 208 | | |
Antulius | 0:261e911dcf75 | 209 | | P R O G R A M A P R I N C I P A L |
Antulius | 0:261e911dcf75 | 210 | | |
Antulius | 0:261e911dcf75 | 211 | #=============================================================================== |
Antulius | 0:261e911dcf75 | 212 | */ |
Antulius | 0:261e911dcf75 | 213 | int main() |
Antulius | 0:261e911dcf75 | 214 | { |
Antulius | 0:261e911dcf75 | 215 | //=================== Secuencia Principal ===================================== |
Antulius | 0:261e911dcf75 | 216 | Setup(); // Inicializa el Hardware |
Antulius | 0:261e911dcf75 | 217 | Caratula(); // Carátula de Bienvenida |
Antulius | 0:261e911dcf75 | 218 | lcd.cls(); // Limpia la Pantalla LCD |
Antulius | 0:261e911dcf75 | 219 | //=================== Lazo Principal =========================================== |
Antulius | 0:261e911dcf75 | 220 | while (true) // El Lazo del Programa principal está aquí !!! |
Antulius | 0:261e911dcf75 | 221 | { |
Antulius | 0:261e911dcf75 | 222 | lcd.cls(); |
Antulius | 0:261e911dcf75 | 223 | lcd.locate(0,0); |
Antulius | 0:261e911dcf75 | 224 | lcd.printf("Bienvenidos Sean"); // El LCD saluda al Mundo |
Antulius | 0:261e911dcf75 | 225 | lcd.printf(" a la \n"); // y a la |
Antulius | 0:261e911dcf75 | 226 | lcd.setInvert(ON); |
Antulius | 0:261e911dcf75 | 227 | lcd.printf("Gloriosa ESIME !\n"); // Gloriosa ESIME ! |
Antulius | 0:261e911dcf75 | 228 | lcd.setInvert(OFF); |
Antulius | 0:261e911dcf75 | 229 | lcd.locate(0,4); |
Antulius | 0:261e911dcf75 | 230 | lcd.printf("Flashings: %d",heartbeat); // Led Flasings Transcurridos |
Antulius | 0:261e911dcf75 | 231 | wait(0.5); |
Antulius | 0:261e911dcf75 | 232 | // Blinking_Led(); // Parapadeo del LED por Software |
Antulius | 0:261e911dcf75 | 233 | } |
Antulius | 0:261e911dcf75 | 234 | } |
Antulius | 0:261e911dcf75 | 235 | /* END main */ |
Antulius | 0:261e911dcf75 | 236 | |
Antulius | 0:261e911dcf75 | 237 | /* |
Antulius | 0:261e911dcf75 | 238 | ................................................................................ |
Antulius | 0:261e911dcf75 | 239 | : Rutinas de los Vectores de Interrupción |
Antulius | 0:261e911dcf75 | 240 | ................................................................................ |
Antulius | 0:261e911dcf75 | 241 | */ |
Antulius | 0:261e911dcf75 | 242 | /* |
Antulius | 0:261e911dcf75 | 243 | ** =================================================================== |
Antulius | 0:261e911dcf75 | 244 | ** Vector : Ticker_OnInterrupt() |
Antulius | 0:261e911dcf75 | 245 | */ |
Antulius | 0:261e911dcf75 | 246 | /*! |
Antulius | 0:261e911dcf75 | 247 | ** @brief |
Antulius | 0:261e911dcf75 | 248 | ** Called after Ticker is done, [Interrupt service/event] |
Antulius | 0:261e911dcf75 | 249 | ** and it is enabled: |
Antulius | 0:261e911dcf75 | 250 | ** TimerInt.attach_us(&Ticker_OnInterrupt, TICKER_RATE); |
Antulius | 0:261e911dcf75 | 251 | ** the event is enabled and will be executed every [TICKER_RATE] |
Antulius | 0:261e911dcf75 | 252 | ** @param |
Antulius | 0:261e911dcf75 | 253 | ** UserDataPtr - Pointer to the user or |
Antulius | 0:261e911dcf75 | 254 | ** RTOS specific data. The pointer is passed |
Antulius | 0:261e911dcf75 | 255 | ** as the parameter of Init method. |
Antulius | 0:261e911dcf75 | 256 | */ |
Antulius | 0:261e911dcf75 | 257 | /* ===================================================================*/ |
Antulius | 0:261e911dcf75 | 258 | void Ticker_OnInterrupt() // Rutina de Atención al Ticker |
Antulius | 0:261e911dcf75 | 259 | { |
Antulius | 0:261e911dcf75 | 260 | counter--; // Aquí va la Rutina de Servicio ! |
Antulius | 0:261e911dcf75 | 261 | if (!counter) |
Antulius | 0:261e911dcf75 | 262 | { |
Antulius | 0:261e911dcf75 | 263 | led_monitor = !led_monitor; // Parapadeo del LED por Interrupción (Toggle the LED) |
Antulius | 0:261e911dcf75 | 264 | if(led_monitor==0) terminal.printf("Led Toggled %d Times!\r",heartbeat); |
Antulius | 0:261e911dcf75 | 265 | heartbeat++; // Incrementa el contador de Pulsaciones |
Antulius | 0:261e911dcf75 | 266 | counter = Rate; // Restablece el contador |
Antulius | 0:261e911dcf75 | 267 | } |
Antulius | 0:261e911dcf75 | 268 | } |
Antulius | 0:261e911dcf75 | 269 | /* END Events */ |
Antulius | 0:261e911dcf75 | 270 | /* |
Antulius | 0:261e911dcf75 | 271 | ________________________________________________________________________________ |
Antulius | 0:261e911dcf75 | 272 | | |
Antulius | 0:261e911dcf75 | 273 | | Funciones Prototipo |
Antulius | 0:261e911dcf75 | 274 | |_______________________________________________________________________________ |
Antulius | 0:261e911dcf75 | 275 | */ |
Antulius | 0:261e911dcf75 | 276 | // Las Funciones Prototipo van aquí ! |
Antulius | 0:261e911dcf75 | 277 | /* |
Antulius | 0:261e911dcf75 | 278 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 279 | | Función : Caratula() |
Antulius | 0:261e911dcf75 | 280 | | |
Antulius | 0:261e911dcf75 | 281 | | Descripción : Rutina que muestra la Carátula de Bienvenida en la |
Antulius | 0:261e911dcf75 | 282 | | Terminal Serial |
Antulius | 0:261e911dcf75 | 283 | | |
Antulius | 0:261e911dcf75 | 284 | | Parámetros : Ninguno |
Antulius | 0:261e911dcf75 | 285 | | |
Antulius | 0:261e911dcf75 | 286 | | Retorna : Nada |
Antulius | 0:261e911dcf75 | 287 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 288 | */ |
Antulius | 0:261e911dcf75 | 289 | void Caratula() // Carátula de Bienvenida |
Antulius | 0:261e911dcf75 | 290 | { terminal.printf ("\t\e[1;37;41mInstituto Politecnico Nacional\e[0m\n\r"); |
Antulius | 0:261e911dcf75 | 291 | terminal.printf ("\e[1;37;42mESCUELA SUPERIOR DE INGENIERIA MECANICA Y ELECTRICA\e[0m\n\r\v"); |
Antulius | 0:261e911dcf75 | 292 | terminal.printf ("\t\e[1;31;40mPrueba \e[1;35;40mde \e[1;33;40mla \e[1;34;40mPantalla \e[1;32;40mLCD \e[0m\n\r\v\v\e[0m"); |
Antulius | 0:261e911dcf75 | 293 | } |
Antulius | 0:261e911dcf75 | 294 | /* |
Antulius | 0:261e911dcf75 | 295 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 296 | | Función : Setup() |
Antulius | 0:261e911dcf75 | 297 | | |
Antulius | 0:261e911dcf75 | 298 | | Descripción : Rutina para inicialización de los puertos y funciones |
Antulius | 0:261e911dcf75 | 299 | | de la Bluepill |
Antulius | 0:261e911dcf75 | 300 | | |
Antulius | 0:261e911dcf75 | 301 | | Parámetros : Ninguno |
Antulius | 0:261e911dcf75 | 302 | | |
Antulius | 0:261e911dcf75 | 303 | | Retorna : Nada |
Antulius | 0:261e911dcf75 | 304 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 305 | */ |
Antulius | 0:261e911dcf75 | 306 | void Setup() // Inicialización del Hardware del Sistema |
Antulius | 0:261e911dcf75 | 307 | { |
Antulius | 0:261e911dcf75 | 308 | /* Inicia la comunicación la Terminal */ /* 115200 Bauds, 8 bits, 1 stop, N parity */ |
Antulius | 0:261e911dcf75 | 309 | terminal.baud(115200); // Se inicia la comunicación serial. |
Antulius | 0:261e911dcf75 | 310 | terminal.printf("Beginig Start Up, Please wait...\n\r"); |
Antulius | 0:261e911dcf75 | 311 | /* Prueba del Buzzer */ |
Antulius | 0:261e911dcf75 | 312 | terminal.printf("Testing Buzzer... \n\r"); |
Antulius | 0:261e911dcf75 | 313 | Buzzer_Beep(); |
Antulius | 0:261e911dcf75 | 314 | /* Inicialización del Bluetooth */ |
Antulius | 0:261e911dcf75 | 315 | bluetooth.baud(115200); // Se inicia la comunicación Bluetooth. |
Antulius | 0:261e911dcf75 | 316 | // bluetooth.scanf("%s", buf); //Lee un carácter desde el Bluetooth |
Antulius | 0:261e911dcf75 | 317 | // bluetooth.printf("recv: %s", buf); //Hace eco al Bluetooth |
Antulius | 0:261e911dcf75 | 318 | // terminal.printf("recv: %s\r\n", buf); //Imprime en la Terminal el caracter recibido |
Antulius | 0:261e911dcf75 | 319 | bluetooth.printf("Bluetooth Starting OK! ... \n\r"); |
Antulius | 0:261e911dcf75 | 320 | terminal.printf("Bluetooth Starting OK! ... \n\r"); |
Antulius | 0:261e911dcf75 | 321 | /* Configufración del Display LCD */ /* Mucho OjO !!! */ |
Antulius | 0:261e911dcf75 | 322 | #if LCD_INTERFACE == 1 |
Antulius | 0:261e911dcf75 | 323 | /* LCD Utilizando el I2C */ |
Antulius | 0:261e911dcf75 | 324 | i2c_lcd.frequency(100000); // Frecuencia de operación para el I2C |
Antulius | 0:261e911dcf75 | 325 | i2c_lcd.start(); // Inicio de operación para el I2C |
Antulius | 0:261e911dcf75 | 326 | I2C_Scanner(); // Busca Dispositivos I2C conectados al Bus |
Antulius | 0:261e911dcf75 | 327 | terminal.printf("I2C Initialzed...\n\r"); |
Antulius | 0:261e911dcf75 | 328 | #endif |
Antulius | 0:261e911dcf75 | 329 | #if LCD_INTERFACE == 2 |
Antulius | 0:261e911dcf75 | 330 | /* LCD Utilizando el Puerto SPI */ |
Antulius | 0:261e911dcf75 | 331 | spi_lcd.frequency(1000000); // Frecuencia de operación para el SPI = 1MHz |
Antulius | 0:261e911dcf75 | 332 | spi_lcd.format(8,0); // Número de Bits y Modo de Operación para el SPI |
Antulius | 0:261e911dcf75 | 333 | // SPI1 -> SPIx_C1 |= 0x01; // Formato de la Trama (LSBFE): 0 = MSB (default), 1= LSB |
Antulius | 0:261e911dcf75 | 334 | SSel=FALSE; // Desactiva el Latch del SN74HC595 |
Antulius | 0:261e911dcf75 | 335 | terminal.printf("SPI Initialzed...\n\r"); |
Antulius | 0:261e911dcf75 | 336 | #endif |
Antulius | 0:261e911dcf75 | 337 | /* Prueba de operación de la Interfaz al LCD */ |
Antulius | 0:261e911dcf75 | 338 | #if LCD_INTERFACE == 1 |
Antulius | 0:261e911dcf75 | 339 | terminal.printf("LCD on I2C interface Address: 0x%X, \n\r",I2C_ADDRESS); |
Antulius | 0:261e911dcf75 | 340 | #endif |
Antulius | 0:261e911dcf75 | 341 | #if LCD_INTERFACE == 2 |
Antulius | 0:261e911dcf75 | 342 | terminal.printf("LCD on SPI interface \n\r"); |
Antulius | 0:261e911dcf75 | 343 | if ((SPI1 -> SPIx_C1 & 0x01) > 0) terminal.printf ("SPI LSB First \n\r"); |
Antulius | 0:261e911dcf75 | 344 | else terminal.printf ("SPI MSB First \n\r"); |
Antulius | 0:261e911dcf75 | 345 | #endif |
Antulius | 0:261e911dcf75 | 346 | /* Prueba de operación del LCD */ |
Antulius | 0:261e911dcf75 | 347 | terminal.printf("LCD Test, please wait...\n\r"); |
Antulius | 0:261e911dcf75 | 348 | Test_LCD(); // Rutina de prueba del LCD |
Antulius | 0:261e911dcf75 | 349 | terminal.printf("LCD Initialized Succesfuly...\n\r"); |
Antulius | 0:261e911dcf75 | 350 | /* Arranque de la interrupción por el Ticker */ |
Antulius | 0:261e911dcf75 | 351 | terminal.printf("Ticker Starting Now...\n\r"); |
Antulius | 0:261e911dcf75 | 352 | TimerInt.attach_us(&Ticker_OnInterrupt, TICKER_RATE); // Le asigna el periodo de interrupción de 1ms (TICKER_RATE=1000) |
Antulius | 0:261e911dcf75 | 353 | } // end of Setup |
Antulius | 0:261e911dcf75 | 354 | /* |
Antulius | 0:261e911dcf75 | 355 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 356 | | Función : Test_LCD() |
Antulius | 0:261e911dcf75 | 357 | | |
Antulius | 0:261e911dcf75 | 358 | | Descripción : Rutina para inicialización del LCD y funciones |
Antulius | 0:261e911dcf75 | 359 | | de la Bluepill |
Antulius | 0:261e911dcf75 | 360 | | |
Antulius | 0:261e911dcf75 | 361 | | Parámetros : Ninguno |
Antulius | 0:261e911dcf75 | 362 | | |
Antulius | 0:261e911dcf75 | 363 | | Retorna : Nada |
Antulius | 0:261e911dcf75 | 364 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 365 | */ |
Antulius | 0:261e911dcf75 | 366 | void Test_LCD() |
Antulius | 0:261e911dcf75 | 367 | { |
Antulius | 0:261e911dcf75 | 368 | // lcd.init(TextLCD::LCDDatalength, 4 ); // Configura el LCD en Modo 4 Bits (Modo GPIO) |
Antulius | 0:261e911dcf75 | 369 | lcd.setBacklight(TextLCD::LightOn); // Enciende la Iluminación de Fondo |
Antulius | 0:261e911dcf75 | 370 | lcd.setCursor(TextLCD::CurOff_BlkOff); // Apaga el Cursor y Apaga el Parpadeo |
Antulius | 0:261e911dcf75 | 371 | lcd.cls(); // Limpia la Pantalla LCD |
Antulius | 0:261e911dcf75 | 372 | lcd.locate(0,0); // Ubica cursor en Col, Ren |
Antulius | 0:261e911dcf75 | 373 | lcd.printf("Hello World!\n"); // El LCD saluda al Mundo! |
Antulius | 0:261e911dcf75 | 374 | lcd.setInvert(ON); |
Antulius | 0:261e911dcf75 | 375 | lcd.printf("Hola Mundo!\n"); // El LCD saluda al Mundo! |
Antulius | 0:261e911dcf75 | 376 | lcd.setInvert(OFF); |
Antulius | 0:261e911dcf75 | 377 | lcd.printf("Ciao Mondo!\n"); // El LCD saluda al Mundo! |
Antulius | 0:261e911dcf75 | 378 | lcd.setInvert(ON); |
Antulius | 0:261e911dcf75 | 379 | lcd.printf("Bonjour le Monde"); // El LCD saluda al Mundo! |
Antulius | 0:261e911dcf75 | 380 | wait(5); |
Antulius | 0:261e911dcf75 | 381 | lcd.cls(); // Limpia el Display LCD |
Antulius | 0:261e911dcf75 | 382 | lcd.setCursor(TextLCD::CurOn_BlkOn); // Cursor Encendido, Parpadeo Encendido |
Antulius | 0:261e911dcf75 | 383 | terminal.printf("TextLCD Enhanced Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows()); |
Antulius | 0:261e911dcf75 | 384 | Timer Elpased_Time; // Inicializa el Tiempo a Transcurrir |
Antulius | 0:261e911dcf75 | 385 | Elpased_Time.start(); // Comienza a contar el tiempo transcurrido |
Antulius | 0:261e911dcf75 | 386 | for (int row=0; row<lcd.rows(); row++)// Prueba toda la Pantalla |
Antulius | 0:261e911dcf75 | 387 | { |
Antulius | 0:261e911dcf75 | 388 | int col=0; |
Antulius | 0:261e911dcf75 | 389 | terminal.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); |
Antulius | 0:261e911dcf75 | 390 | lcd.putc('0' + row); // Enumera los renglones |
Antulius | 0:261e911dcf75 | 391 | for (col=1; col<lcd.columns()-1; col++) |
Antulius | 0:261e911dcf75 | 392 | { |
Antulius | 0:261e911dcf75 | 393 | lcd.putc('*'); // Llena la linea con el carácter "*" |
Antulius | 0:261e911dcf75 | 394 | } |
Antulius | 0:261e911dcf75 | 395 | terminal.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); |
Antulius | 0:261e911dcf75 | 396 | lcd.putc('+'); // Al final de la línea agrega el "+" |
Antulius | 0:261e911dcf75 | 397 | } |
Antulius | 0:261e911dcf75 | 398 | Elpased_Time.stop(); // Detiene el Contador de Ticks |
Antulius | 0:261e911dcf75 | 399 | terminal.printf("All my hard work took %f sec\r\n", Elpased_Time.read()); // Calcula el tiempo transcurrido |
Antulius | 0:261e911dcf75 | 400 | wait(1); // Espera por 1 segundo |
Antulius | 0:261e911dcf75 | 401 | terminal.printf("LCD Display and TextLCD Enhanced Test Completed.\n\r"); |
Antulius | 0:261e911dcf75 | 402 | wait(1); // Espera 1 segundo |
Antulius | 0:261e911dcf75 | 403 | lcd.cls(); // Limpia la Pantalla |
Antulius | 0:261e911dcf75 | 404 | // lcd.setBacklight(TextLCD::LightOff); // Apaga la Iluminación de Fondo |
Antulius | 0:261e911dcf75 | 405 | lcd.setCursor(TextLCD::CurOff_BlkOn); // Apaga el Cursor y Enciende el Parpadeo |
Antulius | 0:261e911dcf75 | 406 | // Set and show user defined characters. A maximum of 8 UDCs are supported by the HD44780. |
Antulius | 0:261e911dcf75 | 407 | // They are defined by a 5x7 bitpattern. |
Antulius | 0:261e911dcf75 | 408 | lcd.setUDC(0, (char *) udc_0); // Selecciona el caracter para el cursor |> |
Antulius | 0:261e911dcf75 | 409 | lcd.putc(0); // Lo imprime en la Pantalla LCD |
Antulius | 0:261e911dcf75 | 410 | lcd.printf(" LCD Ready... "); // El LCD está listo para usarse |
Antulius | 0:261e911dcf75 | 411 | wait(2); // Espera 2 segundos |
Antulius | 0:261e911dcf75 | 412 | lcd.setCursor(TextLCD::CurOff_BlkOff); // Apaga el Cursor y Apaga el Parpadeo |
Antulius | 0:261e911dcf75 | 413 | terminal.printf("LCD Starting OK! ... \n\r"); |
Antulius | 0:261e911dcf75 | 414 | } // end of Test_LCD |
Antulius | 0:261e911dcf75 | 415 | |
Antulius | 0:261e911dcf75 | 416 | /* |
Antulius | 0:261e911dcf75 | 417 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 418 | | Función : Buzzer_Beep() |
Antulius | 0:261e911dcf75 | 419 | | |
Antulius | 0:261e911dcf75 | 420 | | Descripción : Rutina para prueba del Buzzer |
Antulius | 0:261e911dcf75 | 421 | | |
Antulius | 0:261e911dcf75 | 422 | | Parámetros : Ninguno |
Antulius | 0:261e911dcf75 | 423 | | |
Antulius | 0:261e911dcf75 | 424 | | Retorna : Nada |
Antulius | 0:261e911dcf75 | 425 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 426 | */ |
Antulius | 0:261e911dcf75 | 427 | void Buzzer_Beep() // Software routine for Buzzer Beep |
Antulius | 0:261e911dcf75 | 428 | { |
Antulius | 0:261e911dcf75 | 429 | // terminal.printf("Testing Buzzer... \n\r"); |
Antulius | 0:261e911dcf75 | 430 | buzzer = BUZZ_ON; |
Antulius | 0:261e911dcf75 | 431 | wait_ms(750); |
Antulius | 0:261e911dcf75 | 432 | buzzer = BUZZ_OFF; |
Antulius | 0:261e911dcf75 | 433 | wait_ms(125); |
Antulius | 0:261e911dcf75 | 434 | buzzer = BUZZ_ON; |
Antulius | 0:261e911dcf75 | 435 | wait_ms(250); |
Antulius | 0:261e911dcf75 | 436 | buzzer = BUZZ_OFF; |
Antulius | 0:261e911dcf75 | 437 | wait_ms(125); |
Antulius | 0:261e911dcf75 | 438 | buzzer = BUZZ_ON; |
Antulius | 0:261e911dcf75 | 439 | wait_ms(500); |
Antulius | 0:261e911dcf75 | 440 | buzzer = BUZZ_OFF; |
Antulius | 0:261e911dcf75 | 441 | // terminal.printf("Buzzer OK ! \n\r"); |
Antulius | 0:261e911dcf75 | 442 | } |
Antulius | 0:261e911dcf75 | 443 | /* |
Antulius | 0:261e911dcf75 | 444 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 445 | | Función : Blinking_Led() |
Antulius | 0:261e911dcf75 | 446 | | |
Antulius | 0:261e911dcf75 | 447 | | Descripción : Rutina de parpadeo del Led por software |
Antulius | 0:261e911dcf75 | 448 | | |
Antulius | 0:261e911dcf75 | 449 | | Parámetros : Ninguno |
Antulius | 0:261e911dcf75 | 450 | | |
Antulius | 0:261e911dcf75 | 451 | | Retorna : Nada |
Antulius | 0:261e911dcf75 | 452 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 453 | */ |
Antulius | 0:261e911dcf75 | 454 | void Blinking_Led() // Software Blinking routine for LED |
Antulius | 0:261e911dcf75 | 455 | { |
Antulius | 0:261e911dcf75 | 456 | // The on-board LED is connected, via a resistor, to +3.3V (not to GND). |
Antulius | 0:261e911dcf75 | 457 | // So to turn the LED on or off we have to set it to 0 or 1 respectively |
Antulius | 0:261e911dcf75 | 458 | led_monitor = 0; // turn the LED on |
Antulius | 0:261e911dcf75 | 459 | wait_ms(200); // 200 millisecond |
Antulius | 0:261e911dcf75 | 460 | led_monitor = 1; // turn the LED off |
Antulius | 0:261e911dcf75 | 461 | wait_ms(1000); // 1000 millisecond |
Antulius | 0:261e911dcf75 | 462 | } |
Antulius | 0:261e911dcf75 | 463 | /* |
Antulius | 0:261e911dcf75 | 464 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 465 | | Función : I2C_Scanner() |
Antulius | 0:261e911dcf75 | 466 | | |
Antulius | 0:261e911dcf75 | 467 | | Descripción : Rutina de parpadeo del Led por software |
Antulius | 0:261e911dcf75 | 468 | | |
Antulius | 0:261e911dcf75 | 469 | | Parámetros : Ninguno |
Antulius | 0:261e911dcf75 | 470 | | |
Antulius | 0:261e911dcf75 | 471 | | Retorna : Nada |
Antulius | 0:261e911dcf75 | 472 | |------------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 473 | */ |
Antulius | 0:261e911dcf75 | 474 | void I2C_Scanner() |
Antulius | 0:261e911dcf75 | 475 | { |
Antulius | 0:261e911dcf75 | 476 | #if LCD_INTERFACE == 1 |
Antulius | 0:261e911dcf75 | 477 | terminal.printf ("I2C scanner. Scanning ..."); |
Antulius | 0:261e911dcf75 | 478 | uint8_t count = 0; |
Antulius | 0:261e911dcf75 | 479 | char test[] = { 0b00000000, 0b00000000, // RS=0, EN=1,0, LED+=1, NC, DB4=DB5=DB6=DB7=0 en datos |
Antulius | 0:261e911dcf75 | 480 | 0b01101100, 0b00101100, // RS=0, EN=1,0, LED+=1, NC, DB4=DB5=1 en datos, |
Antulius | 0:261e911dcf75 | 481 | 0b01101100, 0b00101100, // RS=0, EN=1,0, LED+=1, NC, DB4=DB5=1 en datos, |
Antulius | 0:261e911dcf75 | 482 | 0b01101100, 0b00101100, // RS=0, EN=1,0, LED+=1, NC, DB4=DB5=1 en datos, |
Antulius | 0:261e911dcf75 | 483 | 0b01100100, 0b00100100, // RS=0, EN=1,0, LED+=1, NC, DB5=1 en datos, |
Antulius | 0:261e911dcf75 | 484 | 0b01100100, 0b00100100, // RS=0, EN=1,0, LED+=1, NC, DB5=1 en datos, |
Antulius | 0:261e911dcf75 | 485 | 0b01100110, 0b00100001, // RS=0, EN=1,0, LED+=1, NC, DB7=N=1 2 líneas, DB6=F=0 5x7puntos, |
Antulius | 0:261e911dcf75 | 486 | 0b01100000, 0b00100000, // => Display ON/OFF Control. |
Antulius | 0:261e911dcf75 | 487 | 0b01100001, 0b00100001, // RS=0, EN=1,0, LED+=1, NC, DB7=1 (Display off, cursor off, blink off) |
Antulius | 0:261e911dcf75 | 488 | 0b01100000, 0b00100000, // => Display Clear. |
Antulius | 0:261e911dcf75 | 489 | 0b01101000, 0b00101000};// RS=0, EN=1,0, LED+=1, NC, DB4=1 en datos, (Cursor Home}; // Patrón de Prueba |
Antulius | 0:261e911dcf75 | 490 | |
Antulius | 0:261e911dcf75 | 491 | // char test[] = {0x55,0xAA,0x0F,0xF0,0xFF,0x00};// Patrón de Prueba |
Antulius | 0:261e911dcf75 | 492 | i2c_lcd.frequency(100000); // Frecuencia de operación para el I2C (100KHz) |
Antulius | 0:261e911dcf75 | 493 | i2c_lcd.start(); // Inicio de operación para el I2C |
Antulius | 0:261e911dcf75 | 494 | for (int i = 8; i < 128; i++) |
Antulius | 0:261e911dcf75 | 495 | { |
Antulius | 0:261e911dcf75 | 496 | uint8_t acknoledge = i2c_lcd.write (i,test,22,1); //(dirección, ap_datos, N°_datos, repetición) |
Antulius | 0:261e911dcf75 | 497 | if (acknoledge == 0) |
Antulius | 0:261e911dcf75 | 498 | { |
Antulius | 0:261e911dcf75 | 499 | terminal.printf ("\n\rFound address: "); |
Antulius | 0:261e911dcf75 | 500 | terminal.printf ("%u DEC",i); // Valor de la dirección en Decimal |
Antulius | 0:261e911dcf75 | 501 | terminal.printf (" (0x%x HEX)\n\r",i);// Valor de la dirección en Hexadecimal |
Antulius | 0:261e911dcf75 | 502 | char data = i2c_lcd.read (i); // Lee el dato en la dirección |
Antulius | 0:261e911dcf75 | 503 | terminal.printf ("Data: (0x%hd HEX)\n\r",data); // Valor del último dato en la dirección en Hexadecimal |
Antulius | 0:261e911dcf75 | 504 | count++; |
Antulius | 0:261e911dcf75 | 505 | |
Antulius | 0:261e911dcf75 | 506 | wait (1); // maybe unneeded? |
Antulius | 0:261e911dcf75 | 507 | } // end of good response |
Antulius | 0:261e911dcf75 | 508 | led_monitor = !led_monitor; // Parapadeo del LED |
Antulius | 0:261e911dcf75 | 509 | } // end of for loop |
Antulius | 0:261e911dcf75 | 510 | led_monitor = 1; // Apaga el LED |
Antulius | 0:261e911dcf75 | 511 | i2c_lcd.stop(); // Fin de operación para el I2C |
Antulius | 0:261e911dcf75 | 512 | terminal.printf ("\n\rDone.\n\r"); |
Antulius | 0:261e911dcf75 | 513 | terminal.printf ("Found %d Device(s)\n\r",count); |
Antulius | 0:261e911dcf75 | 514 | #endif |
Antulius | 0:261e911dcf75 | 515 | } // end of I2C_Scanner |
Antulius | 0:261e911dcf75 | 516 | |
Antulius | 0:261e911dcf75 | 517 | /* END Program */ |
Antulius | 0:261e911dcf75 | 518 | |
Antulius | 0:261e911dcf75 | 519 | /*+----------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 520 | *+ Direccinamiento de la RAM del Display: |
Antulius | 0:261e911dcf75 | 521 | *+ |
Antulius | 0:261e911dcf75 | 522 | *+ Los módulos de 8x1 (obsoletos) están arreglados como una líneas de |
Antulius | 0:261e911dcf75 | 523 | *+ 8 caracteres de lada a lado. |
Antulius | 0:261e911dcf75 | 524 | *+ "Linea 1" Las direcciones comienzan en 80h a 87h |
Antulius | 0:261e911dcf75 | 525 | *+ |
Antulius | 0:261e911dcf75 | 526 | *+ Los módulos de 16x1 están arreglados como dos líneas de 8 caracteres de lada a lado. |
Antulius | 0:261e911dcf75 | 527 | *+ "Linea 1" Las direcciones comienzan en 80h a 87h (primera parte de la línea) |
Antulius | 0:261e911dcf75 | 528 | *+ "Linea 1" Las direcciones comienzan en C0h a C7h (segunda parte de la línea) |
Antulius | 0:261e911dcf75 | 529 | *+ de manera que al escribir caracteres al módulo, el cursor se incrementará automaticamente |
Antulius | 0:261e911dcf75 | 530 | *+ hasta alcanzar el 9° caracter entonces tendrá que mover el cursor a la dirección C0h antes |
Antulius | 0:261e911dcf75 | 531 | *+ de escribir el 9° caracter en el módulo de 1x16. |
Antulius | 0:261e911dcf75 | 532 | *+ |
Antulius | 0:261e911dcf75 | 533 | *+ Módulo de 16x2 es dos líneas por 16 caracteres |
Antulius | 0:261e911dcf75 | 534 | *+ "Linea 1" Las direcciones comienzan en 80h a 8Fh |
Antulius | 0:261e911dcf75 | 535 | *+ "Linea 2" Las direcciones comienzan en C0h a CFh |
Antulius | 0:261e911dcf75 | 536 | *+ |
Antulius | 0:261e911dcf75 | 537 | *+ Módulo de 16x4 |
Antulius | 0:261e911dcf75 | 538 | *+ "Linea 1" Las direcciones comienzan en 80h a 8Fh |
Antulius | 0:261e911dcf75 | 539 | *+ "Linea 2" Las direcciones comienzan en C0h a CFh |
Antulius | 0:261e911dcf75 | 540 | *+ "Linea 3" Las direcciones comienzan en 90h a 9Fh |
Antulius | 0:261e911dcf75 | 541 | *+ "Linea 4" Las direcciones comienzan en D0h a DFh |
Antulius | 0:261e911dcf75 | 542 | *+ |
Antulius | 0:261e911dcf75 | 543 | *+ Módulo de 20x1 |
Antulius | 0:261e911dcf75 | 544 | *+ "Linea 1" Las direcciones comienzan en 80h a 93h |
Antulius | 0:261e911dcf75 | 545 | *+ |
Antulius | 0:261e911dcf75 | 546 | *+ Módulo de 20x2 |
Antulius | 0:261e911dcf75 | 547 | *+ "Linea 1" Las direcciones comienzan en 80h a 93h |
Antulius | 0:261e911dcf75 | 548 | *+ "Linea 2" Las direcciones comienzan en C0h a D3h |
Antulius | 0:261e911dcf75 | 549 | *+ |
Antulius | 0:261e911dcf75 | 550 | *+ Módulo de 20x4 |
Antulius | 0:261e911dcf75 | 551 | *+ "Linea 1" Las direcciones comienzan en 80h a 93h |
Antulius | 0:261e911dcf75 | 552 | *+ "Linea 2" Las direcciones comienzan en C0h a D3h |
Antulius | 0:261e911dcf75 | 553 | *+ "Linea 3" Las direcciones comienzan en 94h a A7h |
Antulius | 0:261e911dcf75 | 554 | *+ "Linea 4" Las direcciones comienzan en D4h a E7h |
Antulius | 0:261e911dcf75 | 555 | *+ |
Antulius | 0:261e911dcf75 | 556 | *+ Módulo de 24x2 |
Antulius | 0:261e911dcf75 | 557 | *+ "Linea 1" Las direcciones comienzan en 80h a 98h |
Antulius | 0:261e911dcf75 | 558 | *+ "Linea 2" Las direcciones comienzan en C0h a D8h |
Antulius | 0:261e911dcf75 | 559 | *+ |
Antulius | 0:261e911dcf75 | 560 | *+ Módulo de 32x2 |
Antulius | 0:261e911dcf75 | 561 | *+ "Linea 1" Las direcciones comienzan en 80h a A0h |
Antulius | 0:261e911dcf75 | 562 | *+ "Linea 2" Las direcciones comienzan en C0h a E0h |
Antulius | 0:261e911dcf75 | 563 | *+ |
Antulius | 0:261e911dcf75 | 564 | *+ Módulo de 40x2 |
Antulius | 0:261e911dcf75 | 565 | *+ "Linea 1" Las direcciones comienzan en 80h a A7h |
Antulius | 0:261e911dcf75 | 566 | *+ "Linea 2" Las direcciones comienzna en C0h a E7h |
Antulius | 0:261e911dcf75 | 567 | *+ |
Antulius | 0:261e911dcf75 | 568 | *+ |
Antulius | 0:261e911dcf75 | 569 | *+--------------------------------------------------------------------------- */ |
Antulius | 0:261e911dcf75 | 570 | |
Antulius | 0:261e911dcf75 | 571 | /*+----------------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 572 | *+ Inicializaci¢n del Display de Cristal Líquido Alfanumérico en modo de 4 bits |
Antulius | 0:261e911dcf75 | 573 | *+ |
Antulius | 0:261e911dcf75 | 574 | *+ Definici¢n de pines: |
Antulius | 0:261e911dcf75 | 575 | *+ __ Vdd GND |
Antulius | 0:261e911dcf75 | 576 | *+ MOSI MISO SCK SS | | |
Antulius | 0:261e911dcf75 | 577 | *+ | | | | 10K | |
Antulius | 0:261e911dcf75 | 578 | *+ | | | | | | |
Antulius | 0:261e911dcf75 | 579 | *+ CD 4094 DATA NC CLOCK STROBE NC OE QS ---> DATA en la siguiente etapa |
Antulius | 0:261e911dcf75 | 580 | *+ 74HC 595 SER NC SCLK RCLK SCLR G QH' ---> SER en la siguiente etapa |
Antulius | 0:261e911dcf75 | 581 | *+ |
Antulius | 0:261e911dcf75 | 582 | *+ CD 4094 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 |
Antulius | 0:261e911dcf75 | 583 | *+ 74HC 595 QA QB QC QD QE QF QG QH |
Antulius | 0:261e911dcf75 | 584 | *+ | | | | | | | | |
Antulius | 0:261e911dcf75 | 585 | *+ | | | | | | | | |
Antulius | 0:261e911dcf75 | 586 | *+ HD44780 R/S RW E BL DB4 DB5 DB6 DB7 |
Antulius | 0:261e911dcf75 | 587 | *+ |
Antulius | 0:261e911dcf75 | 588 | *+ Notas: El pin RW del LCD debe estar estar siempre en "L" o conectado a GND. |
Antulius | 0:261e911dcf75 | 589 | *+ El pin E2 es usado solo para el LCD40x4 (segundo controlador) |
Antulius | 0:261e911dcf75 | 590 | *+ La señal BL = LED+ y debe ser usado para control del Backlight |
Antulius | 0:261e911dcf75 | 591 | *+ Para enviar cualquier dato o instrucci¢n hay que hacer una _ |
Antulius | 0:261e911dcf75 | 592 | *+ transici¢n de bajo a alto en el pin de E (Enable) del LCD. _| |_ |
Antulius | 0:261e911dcf75 | 593 | *+ |
Antulius | 0:261e911dcf75 | 594 | *+------------------------------------------------------------------------------ |
Antulius | 0:261e911dcf75 | 595 | *+ |
Antulius | 0:261e911dcf75 | 596 | *+ Ubicaciónn de pines: |
Antulius | 0:261e911dcf75 | 597 | *+ --------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 598 | *+ | _______________________________________________________________ | |
Antulius | 0:261e911dcf75 | 599 | *+ | | | | |
Antulius | 0:261e911dcf75 | 600 | *+ | | | | |
Antulius | 0:261e911dcf75 | 601 | *+ | | | | |
Antulius | 0:261e911dcf75 | 602 | *+ | | | | |
Antulius | 0:261e911dcf75 | 603 | *+ | | | | |
Antulius | 0:261e911dcf75 | 604 | *+ | | | | |
Antulius | 0:261e911dcf75 | 605 | *+ | |_______________________________________________________________| | |
Antulius | 0:261e911dcf75 | 606 | *+ | | |
Antulius | 0:261e911dcf75 | 607 | *+ --------------------------------------------------------------------- |
Antulius | 0:261e911dcf75 | 608 | *+ | | | | | | | | | | | | | | | | |
Antulius | 0:261e911dcf75 | 609 | *+ | | | | | | | | | | | | | | | | |
Antulius | 0:261e911dcf75 | 610 | *+ 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 |
Antulius | 0:261e911dcf75 | 611 | *+ |
Antulius | 0:261e911dcf75 | 612 | *+ 1 Vss - GND |
Antulius | 0:261e911dcf75 | 613 | *+ 2 Vdd - Vcc |
Antulius | 0:261e911dcf75 | 614 | *+ 3 Vee - Ajuste de contraste |
Antulius | 0:261e911dcf75 | 615 | *+ 4 RS - (Register/String) 0=Entrada de Instrucción, 1=Entrada de Dato |
Antulius | 0:261e911dcf75 | 616 | *+ 5 RW - Lectura/Escritura 0=Escribe al LCD, 1=Lee del LCD |
Antulius | 0:261e911dcf75 | 617 | *+ 6 E - Señal de Habilitación "101" |
Antulius | 0:261e911dcf75 | 618 | *+ 7 DB0 - Línea 0 del bus de datos |
Antulius | 0:261e911dcf75 | 619 | *+ 8 DB1 - Línea 1 del bus de datos |
Antulius | 0:261e911dcf75 | 620 | *+ 9 DB2 - Línea 2 del bus de datos |
Antulius | 0:261e911dcf75 | 621 | *+ 10 DB3 - Línea 3 del bus de datos _ |
Antulius | 0:261e911dcf75 | 622 | *+ 11 DB4 - Línea 4 del bus de datos | |
Antulius | 0:261e911dcf75 | 623 | *+ 12 DB5 - Línea 5 del bus de datos \ Operación en 4 bits |
Antulius | 0:261e911dcf75 | 624 | *+ 13 DB6 - Línea 6 del bus de datos / |
Antulius | 0:261e911dcf75 | 625 | *+ 14 DB7 - Línea 7 del bus de datos _| |
Antulius | 0:261e911dcf75 | 626 | *+ 15 LED+ Ánodo Backlight |
Antulius | 0:261e911dcf75 | 627 | *+ 16 LED- Cátodo Backlight |
Antulius | 0:261e911dcf75 | 628 | *+ |
Antulius | 0:261e911dcf75 | 629 | *+------------------------------------------------------------------------------ |
Antulius | 0:261e911dcf75 | 630 | *+ |
Antulius | 0:261e911dcf75 | 631 | *+ +5V ------------*----------- Vcc PTE19 PTE18 PTE20 PTE21 PTE22 PTE23 |
Antulius | 0:261e911dcf75 | 632 | *+ | RS E D4 D5 D6 D7 |
Antulius | 0:261e911dcf75 | 633 | *+ / |
Antulius | 0:261e911dcf75 | 634 | *+ 10k to \<---------- Vee R/W ---> GND |
Antulius | 0:261e911dcf75 | 635 | *+ 20k pot / A ---> PWM1 o R=330 ---> Vcc |
Antulius | 0:261e911dcf75 | 636 | *+ \ K ---> GND |
Antulius | 0:261e911dcf75 | 637 | *+ | |
Antulius | 0:261e911dcf75 | 638 | *+ GND ------------*----------- Vss |
Antulius | 0:261e911dcf75 | 639 | *+ |
Antulius | 0:261e911dcf75 | 640 | *+------------------------------------------------------------------------------ |
Antulius | 0:261e911dcf75 | 641 | *+ |
Antulius | 0:261e911dcf75 | 642 | *+ Definici¢n de bits: |
Antulius | 0:261e911dcf75 | 643 | *+ |
Antulius | 0:261e911dcf75 | 644 | *+ I/D=1: (Increment/Decrement) Incremento (+) del Cursor |
Antulius | 0:261e911dcf75 | 645 | *+ I/D=0: (Increment/Decrement) Decremento (-) del Cursor |
Antulius | 0:261e911dcf75 | 646 | *+ D=0: (Display) Apaga el Display |
Antulius | 0:261e911dcf75 | 647 | *+ D=1: (Display) Enciende el Display |
Antulius | 0:261e911dcf75 | 648 | *+ C=0: (Cursor) Apaga el Cursor |
Antulius | 0:261e911dcf75 | 649 | *+ C=1: (Cursor) Enciende el Cursor |
Antulius | 0:261e911dcf75 | 650 | *+ B=0: (Blinking) Apaga el parpadeo del Cursor |
Antulius | 0:261e911dcf75 | 651 | *+ B=1: (Blinking) Enciende el parpadeo del Cursor |
Antulius | 0:261e911dcf75 | 652 | *+ S=0: (Shift) Sin corrimiento del Display |
Antulius | 0:261e911dcf75 | 653 | *+ S=1: (Shift) Con corrimiento del Display |
Antulius | 0:261e911dcf75 | 654 | *+ S/C=1: (Shift/Cursor) Con corrimiento del Display |
Antulius | 0:261e911dcf75 | 655 | *+ S/C=0: (Shift/Cursor) Con Movimiento del Cursor |
Antulius | 0:261e911dcf75 | 656 | *+ R/L=1: (Right/Left) Corrimiento a la Derecha |
Antulius | 0:261e911dcf75 | 657 | *+ R/L=0: (Right/Left) Corrimiento a la Izquierda |
Antulius | 0:261e911dcf75 | 658 | *+ DL=1: (Data Lenght) 8 Bits de datos |
Antulius | 0:261e911dcf75 | 659 | *+ DL=0: (Data Lenght) 4 Bits de datos |
Antulius | 0:261e911dcf75 | 660 | *+ N=1: (Number Lines) Modo de 2 Líneas de despliege |
Antulius | 0:261e911dcf75 | 661 | *+ N=0: (Number Lines) Modo de 1 Línea de despliege |
Antulius | 0:261e911dcf75 | 662 | *+ F=1: (Font) 5X10 Puntos por caracter |
Antulius | 0:261e911dcf75 | 663 | *+ F=0: (Font) 5X7 Puntos por caracter |
Antulius | 0:261e911dcf75 | 664 | *+ BF=1: (Busy Flag) Operación interna en proceso |
Antulius | 0:261e911dcf75 | 665 | *+ BF=0: (Busy Flag) Listo para aceptar instrucciones/datos |
Antulius | 0:261e911dcf75 | 666 | *+ DDRAM: (Display Data Ram) |
Antulius | 0:261e911dcf75 | 667 | *+ CGRAM: (Character Generator RAM) |
Antulius | 0:261e911dcf75 | 668 | *+ ACC: Address of CGRAM |
Antulius | 0:261e911dcf75 | 669 | *+ ADD: Address of DDRAM These correspond to curser addresses. |
Antulius | 0:261e911dcf75 | 670 | *+ AC: Address counter used for both DDRAM and CGRAM |
Antulius | 0:261e911dcf75 | 671 | *+ |
Antulius | 0:261e911dcf75 | 672 | *+ RS RW MSB LSB |
Antulius | 0:261e911dcf75 | 673 | *+ Clear Display 0 0 0 0 0 0 0 0 0 1 |
Antulius | 0:261e911dcf75 | 674 | *+ Cursor at Home 0 0 0 0 0 0 0 0 1 0 |
Antulius | 0:261e911dcf75 | 675 | *+ Entry Mode Set 0 0 0 0 0 0 0 1 I/D S |
Antulius | 0:261e911dcf75 | 676 | *+ Display ON/OFF control 0 0 0 0 0 0 1 D C B |
Antulius | 0:261e911dcf75 | 677 | *+ Cursor/Display Shift 0 0 0 0 0 1 S/C R/L x x |
Antulius | 0:261e911dcf75 | 678 | *+ Function Set 0 0 0 0 1 DL N F x x |
Antulius | 0:261e911dcf75 | 679 | *+ CGRAM 0 0 0 1 -------- ACC -------- |
Antulius | 0:261e911dcf75 | 680 | *+ DDRAM 0 0 1 ---------- ADD ---------- |
Antulius | 0:261e911dcf75 | 681 | *+ Busy Flag/Address Read 0 1 1 -----------AC------------ |
Antulius | 0:261e911dcf75 | 682 | *+ CGRAM/CDDRAM Data Write 1 0 Write Data |
Antulius | 0:261e911dcf75 | 683 | *+ CGRAM/CDDRAM Data Read 1 1 Read Data |
Antulius | 0:261e911dcf75 | 684 | *+ |
Antulius | 0:261e911dcf75 | 685 | *+ |
Antulius | 0:261e911dcf75 | 686 | *+ Tiempos de Ejecución: |
Antulius | 0:261e911dcf75 | 687 | *+ Dependiendo del Oscilador Interno del LCD los tiempos de ejecución de las |
Antulius | 0:261e911dcf75 | 688 | *+ instrucciones pueden variar. |
Antulius | 0:261e911dcf75 | 689 | *+ Fosc |
Antulius | 0:261e911dcf75 | 690 | *+ INSTRUCCION 160Khz 250Khz 270Khz |
Antulius | 0:261e911dcf75 | 691 | *+ Clear Display 120us~4.9ms 82us~1.6ms 40us~1.5ms |
Antulius | 0:261e911dcf75 | 692 | *+ Cursor Home 120us 40~1.6ms 37us~1.5ms |
Antulius | 0:261e911dcf75 | 693 | *+ Todas las demás 120us 40us 37us |
Antulius | 0:261e911dcf75 | 694 | *+ Lectura/Escritura 120us 40us 37us |
Antulius | 0:261e911dcf75 | 695 | *+ Lectura de Busy Flag 1us 1us 1us |
Antulius | 0:261e911dcf75 | 696 | |
Antulius | 0:261e911dcf75 | 697 | *+ El controlador podría estar en modo de 8 bits (reinicio de encendido) |
Antulius | 0:261e911dcf75 | 698 | *+ o en modo de 4 bits (reinicio en caliente) en este punto. |
Antulius | 0:261e911dcf75 | 699 | *+ Siga este procedimiento para asegurarse de que el controlador entre en el |
Antulius | 0:261e911dcf75 | 700 | *+ estado correcto. |
Antulius | 0:261e911dcf75 | 701 | *+ |
Antulius | 0:261e911dcf75 | 702 | *+****************************************************************************** |
Antulius | 0:261e911dcf75 | 703 | *+// Patrón de Configuración del LCD en modo de 4 bits (LSN first) |
Antulius | 0:261e911dcf75 | 704 | *+****************************************************************************** |
Antulius | 0:261e911dcf75 | 705 | *+ char init_LCD[] = {0b00000000, 0b00000000, // Datos en DB7=DB6=DB5=DB4=0, LED+=0, EN=0,RW=0,RS=0 |
Antulius | 0:261e911dcf75 | 706 | *+ 0b00111110, 0b00111010, // Datos en DB5=DB4=1, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 707 | *+ 0b00111110, 0b00111010, // Datos en DB5=DB4=1, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 708 | *+ 0b00111110, 0b00111010, // Datos en DB5=DB4=1, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 709 | *+ 0b00101110, 0b00100010, // Datos en DB5=1, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 710 | *+ 0b00101110, 0b00100010, // => Function Set Control: DB5=1, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 711 | *+ 0b10001110, 0b10001110, // => Function Set Control: DB7=N=1 2 líneas, DB6=F=0 5x7puntos, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 712 | *+ 0b00001110, 0b00000010, // => Display ON/OFF Control: DB7=DB6=DB5=DB4=0, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 713 | *+ 0b00101110, 0b00100010, // => Display ON/OFF Control: DB7=1 (Display off, cursor off, blink off),LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 714 | *+ 0b00001110, 0b00000010, // => Display Clear: DB7=DB6=DB5=DB4=0, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 715 | *+ 0b00011110, 0b00010010, // => Display Clear: D4=1, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 716 | *+ 0b00001110, 0b00000010, // => Cursor Home: DB7=DB6=DB5=DB4=0, LED+=1, EN=1,0,RW=1,RS=0 |
Antulius | 0:261e911dcf75 | 717 | *+ 0b00101110, 0b00100010, // => Cursor Home: DB5=1, LED+=1, EN=1,0,RW=1,RS=0 , (Cursor Home}; |
Antulius | 0:261e911dcf75 | 718 | *+ 0b01001111, 0b00001011, // => Text 0x48: DB5=1, LED+=1, EN=1,0,RW=1,RS=1 |
Antulius | 0:261e911dcf75 | 719 | *+ 0b10001111, 0b00101011, // => Text "H" : DB7=1, LED+=1, EN=1,0,RW=1,RS=1 , (ASCII "H"} |
Antulius | 0:261e911dcf75 | 720 | *+ 0b01101111, 0b01101011, // => Text 0x6F: DB5=1, LED+=1, EN=1,0,RW=1,RS=1 |
Antulius | 0:261e911dcf75 | 721 | *+ 0b11111111, 0b11111011, // => Text "o" : DB7=DB6=DB5=DB4=1, LED+=1, EN=1,0,RW=1,RS=1 , (ASCII "o"} |
Antulius | 0:261e911dcf75 | 722 | *+ 0b01101111, 0b01101011, // => Text 0x6C: DB6=DB5=1, LED+=1, EN=1,0,RW=1,RS=1 |
Antulius | 0:261e911dcf75 | 723 | *+ 0b11001111, 0b11001011, // => Text "l" : DB7=DB6=1, LED+=1, EN=1,0,RW=1,RS=1 , (ASCII "l"} |
Antulius | 0:261e911dcf75 | 724 | *+ 0b01101111, 0b01101011, // => Text 0x61: DB6=DB5=1, LED+=1, EN=1,0,RW=1,RS=1 |
Antulius | 0:261e911dcf75 | 725 | *+ 0b00011111, 0b00011011, // => Text "a" : DB4=1, LED+=1, EN=1,0,RW=1,RS=1 , (ASCII "a"} |
Antulius | 0:261e911dcf75 | 726 | *+ 0b00101111, 0b00101011, // => Text 0x21: DB5=1, LED+=1, EN=1,0,RW=1,RS=1 |
Antulius | 0:261e911dcf75 | 727 | *+ 0b00011111, 0b00011011};// => Text "!" : DB4=1, LED+=1, EN=1,0,RW=1,RS=1 , (ASCII "!"} |
Antulius | 0:261e911dcf75 | 728 | *+ |
Antulius | 0:261e911dcf75 | 729 | *+ La interfaz de hardware entre el MCU y la LCD en modo de 8 bits solo puede |
Antulius | 0:261e911dcf75 | 730 | *+ recibir los 4 bits más significativos (Nibble más significativo, MSN) |
Antulius | 0:261e911dcf75 | 731 | *+ como instrucción para cambier a modo 4. |
Antulius | 0:261e911dcf75 | 732 | *+ En el modo de 4 bits, la pantalla LCD espera el MSN primero, seguido del LSN. |
Antulius | 0:261e911dcf75 | 733 | *+----------------------------------------------------------------------------* |
Antulius | 0:261e911dcf75 | 734 | *+ |
Antulius | 0:261e911dcf75 | 735 | *+ Powered by |
Antulius | 0:261e911dcf75 | 736 | *+ |
Antulius | 0:261e911dcf75 | 737 | *+ T H E A N T U L I U ' S T E A M R&D Unltd |
Antulius | 0:261e911dcf75 | 738 | *+ |
Antulius | 0:261e911dcf75 | 739 | *+ Research, Development, Systems, Equipment, Support & Spare Parts. |
Antulius | 0:261e911dcf75 | 740 | *+ (C) Copyright 1989-2019, All Rights Reserved |
Antulius | 0:261e911dcf75 | 741 | *+ |
Antulius | 0:261e911dcf75 | 742 | *+ Welcome to The Beaners Proyect Community! |
Antulius | 0:261e911dcf75 | 743 | *+----------------------------------------------------------------------------*/ |
Antulius | 0:261e911dcf75 | 744 | |
Antulius | 0:261e911dcf75 | 745 | /* END Mbed */ |