Page 1

Por: Omar Gurrola

3/05/13

http://www.proprojects.wordpress.com

PIC18F14K50: LCD con Registro de Desplazamiento (Serial To Parallel) El registro de desplazamiento se puede utilizar como cualquier otro puerto para controlar cualquier dispositivo, en este caso será un LCD. Para lograr esto vamos a juntar la librería del LCD (será la principal) y la del STP (será la de bajo nivel). Tenemos que crear un registro temporal de 8 bits que será utilizado como puerto del LCD y serán los datos a enviar por STP. También debemos tener acceso a cada pin por separado para la lógica del LCD. Para solucionar esto utilizaremos una unión con una estructura y los pines independientes de la siguiente manera: union STPByte{ u8 LCD_DATA; struct{ unsigned unsigned unsigned unsigned unsigned unsigned unsigned unsigned }; }LCDPort;

Q0:1; Q1:1; Q2:1; Q3:1; Q4:1; Q5:1; Q6:1; Q7:1;

//QA-LSB //QB //QC //QD //QE //QF //QG //QH-MSB

El diagrama de bloque es el siguiente:


Por: Omar Gurrola main.c /* * * * * * * * * * * * * * * * * * * * * * */

3/05/13

http://www.proprojects.wordpress.com

Copyright (c) 2011-2013, http://www.proprojects.wordpress.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2.- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/********************************************************************************** * Author: Omar Gurrola * Site: http://www.proprojects.wordpress.com * Processor: PIC18 * Compiler: C18 v3.45 * File Name: main.c * Description: Main program * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Rev. Date Comment * 1.0 04/01/12 Initial version * 1.1 01/29/13 Remove ISR prototipes, they are declared in hid_bl.h *********************************************************************************/ /** INCLUDES *******************************************************/ #include <p18f14k50.h> #include "pic18f14k50_cbits.h" #include "pic18f14k50_io.h" #include "stdvars.h" #include "wait.h" #include "HD44780-STP.h" /** DECLARATIONS ***************************************************/ #pragma code // Forces the code below this line to be put into the code section (Memory Adress >= 0x'REMDIR'02A) /** Interrupt Service Routines (ISR)********************************/ #pragma interrupt HighPriorityISR void HighPriorityISR (void){ //Check which interrupt flag caused the interrupt. //Service the interrupt //Clear the interrupt flag //Etc. } //This return will be a "retfie fast", since this is in a #pragma interrupt section #pragma interruptlow LowPriorityISR void LowPriorityISR (void){ //Check which interrupt flag caused the interrupt. //Service the interrupt //Clear the interrupt flag //Etc. } //This return will be a "retfie", since this is in a #pragma interruptlow section void main(void){ char data[]="Omar Gurrola"; OSCCONbits.IRCF = 0b110; OSCTUNEbits.SPLLEN = 1;

// Poscaler selected to 8 MHz // PLLx4 Enable System FQ = 32 MHz

lcd_initialize(); lcd_goto(1,3); lcd_write(data); lcd_goto(2,3); lcd_write_pgm("Pro Projects"); while(true){ ; } // end while } // end main()

// String in RAM // Goto Line2 // String in ROM


Por: Omar Gurrola Diagrama esquemรกtico:

Circuito armado:

3/05/13

http://www.proprojects.wordpress.com


Por: Omar Gurrola

3/05/13

http://www.proprojects.wordpress.com

Referencias 

Microchip, “PIC18F/LF1XK50 Data Sheet”, 2010, http://ww1.microchip.com/downloads/en/DeviceDoc/41350E.pdf

Texas Instrument, “8-BIT SHIFT REGISTERS WITH 3-STATE OUTPUT REGISTERS - Datasheet”, 2009 http://www.ti.com/lit/ds/symlink/sn74hc595.pdf

DrLuke, “Can you move over? The 74HC595 8 bit shift register”, 2012 http://bildr.org/2011/02/74hc595/

Wayne Storr, “Transistor as a Switch”, 2013 http://www.electronics-tutorials.ws/transistor/tran_4.html

PIC18F14K50: LCD con Registro de Desplazamiento (Serial To Parallel)  

LCD con STP