Autor Tema: Mini curso "Programación en XC8"  (Leído 455461 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: Mini curso "Programación en XC8"
« Respuesta #15 en: 28 de Abril de 2013, 14:52:12 »
  Rseliman, si no me equivoco incluir HTC.H no es necesario. Ése header se usaba cuando el compilador era HiTech, pero al pasar a ser XC8, creo que es suficiente con incluir XC.H

  Por otro lado, sí puedes colocar tus funciones en otros archivos .C y también puedes crear los .H de los mismos para hacer tus propias librerías.
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Mini curso "Programación en XC8"
« Respuesta #16 en: 29 de Abril de 2013, 17:07:17 »
Pregunta ...estoy tratando de hacer una funcion pausa en segundos ...

void pausa (unsigned int num)
{
unsigned int tem;

   tem = num*((4/_XTAL_FREQ)*1000000);
   _delay(tem);
}

Porque esto no funciona en c18 ??

Como lo resuelvo ??

Muchas gracias a todos ??
Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: Mini curso "Programación en XC8"
« Respuesta #17 en: 29 de Abril de 2013, 17:43:06 »
  ¿Qué es lo que pasa? ¿Por qué dices que no funciona? ¿Genera algún error de compilación o no establece bien el tiempo?
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Mini curso "Programación en XC8"
« Respuesta #18 en: 29 de Abril de 2013, 19:28:57 »
  ¿Qué es lo que pasa? ¿Por qué dices que no funciona? ¿Genera algún error de compilación o no establece bien el tiempo?

Porque el _delay no me toma variables ...ese es el error que me da , existe otra forma de generar una funcion para segundos ??

Gracias
Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: Mini curso "Programación en XC8"
« Respuesta #19 en: 29 de Abril de 2013, 19:54:13 »
  Ah, ok.

  Si quieres hacer retardo de segundos puedes implementar algo así...

Código: C
  1. void pausa(unsigned int tiempo)
  2. {
  3.   unsigned int __tiempo;
  4.   for (__tiempo = tiempo; __tiempo > 0; __tiempo--)
  5.   {
  6.     __delay_ms(1000);
  7.   }
  8. }
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Mini curso "Programación en XC8"
« Respuesta #20 en: 30 de Abril de 2013, 15:53:54 »
Hola , sigo con mis preguntas , la verdad , me esta costando bastante adaptarme a este lenguaje , vengo de Mikroc que era muchisimo mas facil ...

Bueno las preguntas son dos

si tengo definido esto

void sonido(int x)  

   {
    while (x > 0)
    {
    buzzer = 1;
    _delay(500);
    buzzer = 0;
    _delay(500);
    x--;
    }

pero esta en el main , y si sigo metiendo voids en el main se me va complicando , como hago para ponerlo como una libreria o sonido.h o sonido.c , no se explicarme para mi seria una macro que la llamo desde el main ...no se si me explico ...muchas gracias


La otra pregunta era ...porque no puedo utilizar _delay_ms ?? veo en muchos ejemplos que la usan y yo no puedo uso #include delay y delays.h y de todas maneras no me deja usar esa funcion ....tampoco pùedo usar delay1ktcyx(50) ....porque me cuesta tanto entender este lenguaje ??

Gracias
« Última modificación: 30 de Abril de 2013, 16:15:51 por Rseliman »
Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado AngelGris

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 2480
Re: Mini curso "Programación en XC8"
« Respuesta #21 en: 30 de Abril de 2013, 20:40:49 »
Hola , sigo con mis preguntas , la verdad , me esta costando bastante adaptarme a este lenguaje , vengo de Mikroc que era muchisimo mas facil ...

Bueno las preguntas son dos

si tengo definido esto

void sonido(int x)  

   {
    while (x > 0)
    {
    buzzer = 1;
    _delay(500);
    buzzer = 0;
    _delay(500);
    x--;
    }

pero esta en el main , y si sigo metiendo voids en el main se me va complicando , como hago para ponerlo como una libreria o sonido.h o sonido.c , no se explicarme para mi seria una macro que la llamo desde el main ...no se si me explico ...muchas gracias


La otra pregunta era ...porque no puedo utilizar _delay_ms ?? veo en muchos ejemplos que la usan y yo no puedo uso #include delay y delays.h y de todas maneras no me deja usar esa funcion ....tampoco pùedo usar delay1ktcyx(50) ....porque me cuesta tanto entender este lenguaje ??

Gracias


  Para hacer una librería puedes crear un archivo.c y un archivo.h cuyo nombre será el de la librería. Dentro de la librería puedes dejar tu función. En el main incluyes tu librería con #include y luego en tu programas puedes llamar a la función. Asegúrate que tengas una copia de tu librería en la carpeta de trabajo de tu proyecto.


pausa.c (librería)

Código: C
  1. void espera(unsigned int tiempo) //espera de x segundos
  2. {
  3.   unsigned int __tiempo;
  4.   for (__tiempo = tiempo; __tiempo > 0; __tiempo--)
  5.   {
  6.     __delay_ms(1000)
  7.   }
  8. }

main.c (Programa principal)

Código: C
  1. #include <xc.h>
  2. #define _XTAL_FREQ 20000000 // defino la frecuencia de oscilacion
  3. // es necesario que este definido _XTAL_FREQ para poder utilizar __delay, __delay_us y __delay_ms
  4. // dichas "funciones" son con 2 guiones bajos delante de la palabra delay
  5.  
  6. #include "pausa.c"
  7.  
  8. void main(void)
  9. {
  10.   while (1)
  11.   {
  12.      // hacer algo...
  13.      espera (12);
  14.   }
  15. }
De vez en cuando la vida
nos besa en la boca
y a colores se despliega
como un atlas

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Mini curso "Programación en XC8"
« Respuesta #22 en: 30 de Abril de 2013, 22:39:11 »
Muchas gracias por tu tiempo Angelgris ...espero poder dentro de poco colaborar yo tambien ....

Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado rotting79

  • PIC12
  • **
  • Mensajes: 91
Re: Mini curso "Programación en XC8"
« Respuesta #23 en: 12 de Mayo de 2013, 19:56:00 »
here is a small project over a PIC12F683  and XC8

...On November 2nd, a PIC10 became self-aware and decided our fate in __delay_us ( 1 ); ...

Desconectado yamilongiano

  • PIC10
  • *
  • Mensajes: 37
Re: Mini curso "Programación en XC8"
« Respuesta #24 en: 14 de Mayo de 2013, 17:04:27 »
hola tengo un problema al compilar (build) con la libreria
hola ya he solucionado mi problema

ahora tengo un problema con el PWM

como puedo programar el PWM para que el T2 del PWM no llegue a 0....osea para que el le nunca quede100% encendido

disculpen que no conosco mucho el lenguaje y estoy aprendiendo el circuito esta en un bucle infinito, pero quiero modificarlo quizas un if que lo reinicie en algun momento.
« Última modificación: 15 de Mayo de 2013, 16:54:35 por yamilongiano »

Desconectado lmtreser

  • PIC16
  • ***
  • Mensajes: 131
    • Automatismos Mar del Plata
Re: Mini curso "Programación en XC8"
« Respuesta #25 en: 19 de Mayo de 2013, 22:23:52 »
1.8. Ejemplo de uso PIC18F4550, delays y USART

Un completo ejemplo de uso sobre el puerto serie que incorpora este microcontrolador. El proyecto completo en un ZIP, probado y compilado en Windows 7 y Ubuntu 10.04.

Código: [Seleccionar]
/*
programa: prueba oscilador interno y módulo usart
pic: 18f4550
crystal: NO
CPU: 8Mhz (valor establecido dentro de main cambiando los bits IRCF2, IRCF1 e IRCF0 del registro OSCCON)
en RA6 sale la frecuencia de Fosc/4   ------->   8Mhz/4 = 2Mhz


CONEXIONES: los cambios se pueden hacer en el archivo configuracion_hard.c
1 led en port b0 con una resistencia en serie de 470ohms
1 led en port b1 con una resistencia en serie de 470ohms

Los leds cambian de estado cada 1 segundo. Uno enciende y el otro se apaga cada vez.
*/

#define _XTAL_FREQ 8000000 // Linea necesario para los cálculos de la función
                           // de delay. CUIDADO. no es para la configuración
                           // de la frecuencia de trabajo del cpu del pic.
                           // eso se determina en otro lado. :)



/*Includes globales*/
#include <pic18.h>
#include <xc.h>
#include <delays.h> /* Para utilizar demoras en nuestro código debemos incluir la librería delays.h.*/
#include <plib/usart.h> //Libreria para el manejo del modulo USART

/*Includes locales*/
#include "configuracion_de_fuses.c"
#include "configuracion_hard.c"


/*declaración de variables globales*/

char CaracterRx;
char MensajeTx[] = "COMUNICACION SATISFACTORIA";

/*declaración de funciones*/
void MyMsDelay(int ms);
//void interrupt Interrupcion();

///////////////////////////////////////////////////////////////////////////////
//                     Programa Principal                                    //
///////////////////////////////////////////////////////////////////////////////


void main(void)
{
// cambiamos la frecuencia del oscilador interno del valor por defecto de 32khz
// a 8mhz mediante los bits del registro OSCCON
    OSCCONbits.IRCF2 = 1;
    OSCCONbits.IRCF1 = 1;
    OSCCONbits.IRCF0 = 1;

    ADCON0 = 0X00,ADCON1 = 0X0F,CMCON = 0X07; //puerto A con todos los pines digitales
    TRISA = 0X00; // puertos A B y C como salida. Recordar Tip: el 0 es una o de ouput y el 1 una I de input!!!
    TRISB = 0X00;
    TRISC = 0X00;
    LATA = 0X00; // ponemos los puertos en cero
    LATB = 0X00;
    LATC = 0X00;
    PINLED0 = 0; // Seteamos el pin como salida para el LED
    PINLED1 = 0; // Seteamos el pin como salida para el LED

// configuramos el puerto serie
 OpenUSART(USART_TX_INT_OFF &
            USART_RX_INT_ON &       //Activar la interrupcion por la recepcion de dato del buffer de Rx del USART
            USART_ASYNCH_MODE &     //Modo asincrono (fullduplex)
            USART_EIGHT_BIT &       //8 bits de datos
            USART_CONT_RX &         //Recepción continua
            USART_BRGH_HIGH, 51);  //9600 Baudios

 // (frecuencia a la que trabaja el cpu/dbaudrate)/16)-1
 // (8.000.000/9600)/16)-1=51






    INTCONbits.PEIE = 1; //Activamos interrupcion de perifericos
    INTCONbits.GIE = 1;  //Activamos las interrupciones globales

    while(BusyUSART());     //Se espera a que el buffer de Tx este libre
    putsUSART(MensajeTx);   //Se envía un string de bienvenida

    while(1){   //Bucle infinito

            LED0 = ~LED0; // Intercambiamos el estado del pin del led (Toggle LED)
            Delay10KTCYx(200); //ver como se hacen los cálculos del delay más abajo
            LED1 = ~LED1; // Intercambiamos el estado del pin del led (Toggle LED)
            }


}

void interrupt Interrupcion()   //Funcion que atiende las interrupciones
{
    CaracterRx = ReadUSART();   //Se lee el dato que esta en el buffer de Rx del USART

    while(BusyUSART());
    putsUSART("\n\rUsted digito la tecla: ");
    while(BusyUSART());
    WriteUSART(CaracterRx);
     PIR1bits.RCIF = 0;  //Desactivamos la bandera de recepción en el buffer de entrada del USART
}




void MyMsDelay(int ms)
{
    while(ms--)
    {
        __delay_ms(1);
    }
}

CÁLCULOS DE LOS RETARDOS

Para utilizar demoras en nuestro código debemos incluir la librería delays.h. En ella tenemos 4 funciones:

Delay10TCYx(i)      ->    10.Tcy.i    genera una demora de 10 ciclos de instrucciones     *   i
Delay100TCYx(i)     ->   100.Tcy.i    genera una demora de 100 ciclos de instrucciones    *   i
Delay1KTCYx(i)      ->  1000.Tcy.i    genera una demora de 1000 ciclos de instrucciones   *   i
Delay10KTCYx(i)     -> 10000.Tcy.i    genera una demora de 10000 ciclos de instrucciones  *   i

i puede tomar un valor de 1 a 255. Si se toma valor 0 i es 256

NOTA: Para hacer los cálculos de los retardos debemos tener en cuenta la frecuencia a la que trabaja la CPU del pic. Y ojo que la velocidad del CPU no siempre será la velocidad del cristal. Podríamos tener un cristal de 4Mhz y hacer trabajar la CPU del pic a 48Mhz mediante el uso del PLL. O trabajar con cristal interno a una frecuencia de 8Mhz y establecer una velocidad de 1 Mhz mediante los postcalers. Comprendido esto podemos pasar a hacer los cálculos.

                                      1
1 ciclo de reloj es =  ---------------------------------
                         Frecuencia que le llega al CPU  (No la Frecuencia del cristal!!!)

1 TCY está formado por 4 ciclos de reloj. 4 ciclos de reloj tarda el pic en procesar una instrucción. Entonces si queremos saber cuanto demora 1 TCY debemos multiplicar 4 veces lo que demora 1 ciclo del reloj del CPU.

                                         1
1 TCY se calcula como  4 * --------
                                       Fosc

donde fosc = frecuencia que llega a la CPU del pic (NO LA FRECUENCIA DEL CRISTAL!!!)

Cálculo de delay para generar 1 segundo con frecuencia de trabajo de CPU a 8mhz

Las funciones de retardos usan como parametro los TCY. Entonces tenemos que calcular cuantos TCY hay que utilizar para obtener 1 segundo. Dijimos que:

                                          1
1 TCY se calcula como  4 * --------
                                        Fosc

Fosc= 8Mhz = 8*10^6 hz = 8.000.000hz

                                            1           1
por lo tanto 1 TCY =  4 * ---------- = ---------- = 0,0000005sec
                                   8*10^6 Hz    2*10^6Hz

              1 TCY = 0,0000005seg = 5*10^-7 seg

Es decir que 1 TCY tarda 0,0000005seg.

Si dividimos 1 sobre TCY nos da la frecuencia en Hertz

              1
            ----- = frecuencia en hertz
             TCY

                    1
            -------------- = frecuencia en hertz
             0,0000005seg.

             2.000.000 Hertz = 2Mhz. Es decir que Fosc oscila 2.000.000 de veces durante 1 segundo

Entoces para calcular un segundo la formula es:

                 1
  1seg * -----------     = 2.000.000 TCYs
          0,0000005 seg

Ahora que sabemos que necesitamos 2.000.000 TCYs para demorar un segundo debemos elegir una de las funciones que nos brinda la librería delays.h debiendo tener presente que sólo reciben como parámetro valores de i de 1 a 255. Si se toma 0 equivale a 256. Para este caso debemos usar la función Delay10KTCYx(i) ya que:

     2.000.000 TCYs
    ----------------- = nos da un valor de 200i
        10.000 TCY

Y con dicho valor 200 logramos el retardo de 1 segundo!

Delay10KTCYx(200); //demora de 1 seg

Gracias a Jukinch por el excelente aporte a este capítulo!
« Última modificación: 28 de Mayo de 2013, 23:24:22 por lmtreser »

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Mini curso "Programación en XC8"
« Respuesta #26 en: 21 de Mayo de 2013, 14:29:37 »
ejemplo de un Pic16f819 controlando un modulo lcd standar 2x16 en 4 bits



Aca les paso un proyecto ..de lcd 2x16 standar , con pic16f819 , Mplabx , XC8 ...en el port B anda perfecto , ahora estoy queriendo desocupar el mismo y llevar todo a PortA , pero no logro hacerlo andar ...si alguien tiene una sugerencia sera bienvenida

Gracias


Main.c
Código: [Seleccionar]
#include <xc.h>
#define _XTAL_FREQ 8000000
#include <stdio.h>
#include <stdlib.h>
#include "lcd_pic16.c"
#include "delay.h"

// PIC16F819 Configuration Bit Settings





//variables globales
unsigned char buffer [14];
// unsigned int contador=0;
//funciones prototipo
void init(void);


void main(void)
{

   OSCCONbits.IRCF2 = 1; //
   OSCCONbits.IRCF1 = 1; // defino oscilador interno en 4 mhz
   OSCCONbits.IRCF0 = 0; //


init();


            
SetDDRamAddr(0x00);
putrsXLCD("Ramiro Seliman");
                putsXLCD(buffer);
                SetDDRamAddr(0x40);
putrsXLCD("Victoria E.R");
        }

void init(void)
{
    ADCON0bits.ADON = 0;

    TRISB=0;    //todo el PORTB como salidas digitales
    PORTB=0;
    OpenXLCD(FOUR_BIT & LINES_5X7 );


}

lcd_pic16.c

Código: [Seleccionar]
/*
 *
 *   Notes:
 *      - These libraries routines are written to support the
 *        Hitachi HD44780 LCD controller.
 *      - The user must define the following items:
 *          - The LCD interface type (4- or 8-bits)
 *          - If 4-bit mode
 *              - whether using the upper or lower nibble
 *          - The data port
 *              - The tris register for data port
 *              - The control signal ports and pins
 *              - The control signal port tris and pins
 *          - The user must provide three delay routines:
 *              - DelayFor18TCY() provides a 18 Tcy delay
 *              - DelayPORXLCD() provides at least 15ms delay
 *              - DelayXLCD() provides at least 5ms delay
 */

/* Interface type 8-bit or 4-bit
 * For 8-bit operation uncomment the #define BIT8
 */
// #define BIT8

/* When in 4-bit interface define if the data is in the upper
 * or lower nibble.  For lower nibble, comment the #define UPPER
 */


#define UPPER

/* When in 6-10-bit interface comment the #define BUSY_LCD and conected PIN
 * R/W to GND in LCD
 */
 //#define BUSY_LCD

/* DATA_PORT defines the port to which the LCD data lines are connected */
 #define DATA_PORT       PORTB
 #define TRIS_DATA_PORT TRISB

/* CTRL_PORT defines the port where the control lines are connected.
 * These are just samples, change to match your application.
 */
 #define RW_PIN   PORTBbits.RB0   /* PORT for RW */
 #define TRIS_RW  TRISBbits.TRISB0     /* TRIS for RW */

 #define RS_PIN   PORTBbits.RB1   /* PORT for RS */
 #define TRIS_RS  TRISBbits.TRISB1     /* TRIS for RS */

 #define E_PIN    PORTBbits.RB2   /* PORT for D  */
 #define TRIS_E   TRISBbits.TRISB2     /* TRIS for E  */

/* Display ON/OFF Control defines */
#define DON         0b00001111  /* Display on      */
#define DOFF        0b00001011  /* Display off     */
#define CURSOR_ON   0b00001111  /* Cursor on       */
#define CURSOR_OFF  0b00001101  /* Cursor off      */
#define BLINK_ON    0b00001111  /* Cursor Blink    */
#define BLINK_OFF   0b00001110  /* Cursor No Blink */

/* Cursor or Display Shift defines */
#define SHIFT_CUR_LEFT    0b00000100  /* Cursor shifts to the left   */
#define SHIFT_CUR_RIGHT   0b00000101  /* Cursor shifts to the right  */
#define SHIFT_DISP_LEFT   0b00000110  /* Display shifts to the left  */
#define SHIFT_DISP_RIGHT  0b00000111  /* Display shifts to the right */

/* Function Set defines */
#define FOUR_BIT   0b00101100  /* 4-bit Interface               */
#define EIGHT_BIT  0b00111100  /* 8-bit Interface               */
#define LINE_5X7   0b00110000  /* 5x7 characters, single line   */
#define LINE_5X10  0b00110100  /* 5x10 characters               */
#define LINES_5X7  0b00111000  /* 5x7 characters, multiple line */

#ifdef _OMNI_CODE_
#define PARAM_SCLASS
#else
#define PARAM_SCLASS auto
#endif

/* CLS_Line2
 * Clear Screen Line 2
 */
void CLS_Line2(void);

/* CLS_Line1
 * Clear Screen Line 1
 */
void CLS_Line1(void);
/* OpenXLCD
 * Configures I/O pins for external LCD
 */
void OpenXLCD(PARAM_SCLASS unsigned char);

/* SetCGRamAddr
 * Sets the character generator address
 */
void SetCGRamAddr(PARAM_SCLASS unsigned char);

/* SetDDRamAddr
 * Sets the display data address
 */
void SetDDRamAddr(PARAM_SCLASS unsigned char);

/* BusyXLCD
 * Returns the busy status of the LCD
 */
unsigned char BusyXLCD(void);

/* ReadAddrXLCD
 * Reads the current address
 */
unsigned char ReadAddrXLCD(void);

/* ReadDataXLCD
 * Reads a byte of data
 */
char ReadDataXLCD(void);

/* WriteCmdXLCD
 * Writes a command to the LCD
 */
void WriteCmdXLCD(PARAM_SCLASS unsigned char);

/* WriteDataXLCD
 * Writes a data byte to the LCD
 */
void WriteDataXLCD(PARAM_SCLASS char);

/* putcXLCD
 * A putc is a write
 */
#define putcXLCD WriteDataXLCD

/* putsXLCD
 * Writes a string of characters to the LCD
 */
void putsXLCD(PARAM_SCLASS char *);

/* putrsXLCD
 * Writes a string of characters in  to the LCD
 */
void putrsXLCD(const char *);

// Rutinas de tiempo auxiliares para la libreria XLCD
void DelayFor18TCY(void)
{
__delay_us(18);
}

void DelayPORXLCD(void)
{
__delay_ms(20); //Delay de 15 ms
}

void DelayXLCD(void)
{
__delay_ms(20); //Delay de 20 ms
}

void CLS_Line2(void)
{
    SetDDRamAddr(0x40);
    putrsXLCD("                ");
}

void CLS_Line1(void)
{
    SetDDRamAddr(0x00);
    putrsXLCD("                ");
}
/********************************************************************
*       Function Name:  OpenXLCD                                    *
*       Return Value:   void                                        *
*       Parameters:     lcdtype: sets the type of LCD (lines)       *
*       Description:    This routine configures the LCD. Based on   *
*                       the Hitachi HD44780 LCD controller. The     *
*                       routine will configure the I/O pins of the  *
*                       microcontroller, setup the LCD for 4- or    *
*                       8-bit mode and clear the display. The user  *
*                       must provide three delay routines:          *
*                       DelayFor18TCY() provides a 18 Tcy delay     *
*                       DelayPORXLCD() provides at least 15ms delay *
*                       DelayXLCD() provides at least 5ms delay     *
********************************************************************/
void OpenXLCD(unsigned char lcdtype)
{
        // The data bits must be either a 8-bit port or the upper or
        // lower 4-bits of a port. These pins are made into inputs
#ifdef BIT8                             // 8-bit mode, use whole port
        DATA_PORT = 0;
        TRIS_DATA_PORT = 0x00;
#else                                   // 4-bit mode
#ifdef UPPER                            // Upper 4-bits of the port
        DATA_PORT &= 0x0f;
        TRIS_DATA_PORT &= 0x0F;
#else                                   // Lower 4-bits of the port
        DATA_PORT &= 0xf0;
        TRIS_DATA_PORT &= 0xF0;
#endif
#endif
        TRIS_RW = 0;                    // All control signals made outputs
        TRIS_RS = 0;
        TRIS_E = 0;
        RW_PIN = 0;                     // R/W pin made low
        RS_PIN = 0;                     // Register select pin made low
        E_PIN = 0;                      // Clock pin made low

        // Delay for 15ms to allow for LCD Power on reset
        DelayPORXLCD();
 //-------------------reset procedure through software----------------------      
WriteCmdXLCD(0x30);
__delay_ms(5);

WriteCmdXLCD(0x30);
__delay_ms(1);


WriteCmdXLCD(0x32);
while( BusyXLCD() );
//------------------------------------------------------------------------------------------


        // Set data interface width, # lines, font
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(lcdtype);          // Function set cmd

        // Turn the display on then off
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(DOFF&CURSOR_OFF&BLINK_OFF);        // Display OFF/Blink OFF
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(DON&CURSOR_ON&BLINK_ON);           // Display ON/Blink ON

        // Clear display
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(0x01);             // Clear display

        // Set entry mode inc, no shift
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(SHIFT_CUR_RIGHT);   // Entry Mode
 
while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(0x06);   // Incremente
 
        while(BusyXLCD());              // Wait if LCD busy
        SetDDRamAddr(0x80);             // Set Display data ram address to 0
        
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(CURSOR_OFF);       // Cursor OFF
        return;
}


/********************************************************************
*       Function Name:  WriteDataXLCD                               *
*       Return Value:   void                                        *
*       Parameters:     data: data byte to be written to LCD        *
*       Description:    This routine writes a data byte to the      *
*                       Hitachi HD44780 LCD controller. The user    *
*                       must check to see if the LCD controller is  *
*                       busy before calling this routine. The data  *
*                       is written to the character generator RAM or*
*                       the display data RAM depending on what the  *
*                       previous SetxxRamAddr routine was called.   *
********************************************************************/
void WriteDataXLCD(char data)
{
#ifdef BIT8                             // 8-bit interface
        TRIS_DATA_PORT = 0;             // Make port output
        DATA_PORT = data;               // Write data to port
        RS_PIN = 1;                     // Set control bits
        RW_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock data into LCD
        DelayFor18TCY();
        E_PIN = 0;
        RS_PIN = 0;                     // Reset control bits
        TRIS_DATA_PORT = 0xff;          // Make port input
#else                                   // 4-bit interface
#ifdef UPPER                            // Upper nibble interface
        TRIS_DATA_PORT &= 0x0f;
        DATA_PORT &= 0x0f;
        DATA_PORT |= data&0xf0;
#else                                   // Lower nibble interface
        TRIS_DATA_PORT &= 0xf0;
        DATA_PORT &= 0xf0;
        DATA_PORT |= ((data>>4)&0x0f);
#endif
        RS_PIN = 1;                     // Set control bits
        RW_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock nibble into LCD
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                            // Upper nibble interface
        DATA_PORT &= 0x0f;
        DATA_PORT |= ((data<<4)&0xf0);
#else                                   // Lower nibble interface
        DATA_PORT &= 0xf0;
        DATA_PORT |= (data&0x0f);
#endif
        DelayFor18TCY();
        E_PIN = 1;                      // Clock nibble into LCD
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                            // Upper nibble interface
        TRIS_DATA_PORT |= 0xf0;
#else                                   // Lower nibble interface
        TRIS_DATA_PORT |= 0x0f;
#endif
#endif
        return;
}

/********************************************************************
*       Function Name:  WriteCmdXLCD                                *
*       Return Value:   void                                        *
*       Parameters:     cmd: command to send to LCD                 *
*       Description:    This routine writes a command to the Hitachi*
*                       HD44780 LCD controller. The user must check *
*                       to see if the LCD controller is busy before *
*                       calling this routine.                       *
********************************************************************/
void WriteCmdXLCD(unsigned char cmd)
{
#ifdef BIT8                             // 8-bit interface
        TRIS_DATA_PORT = 0;             // Data port output
        DATA_PORT = cmd;                // Write command to data port
        RW_PIN = 0;                     // Set the control signals
        RS_PIN = 0;                     // for sending a command
        DelayFor18TCY();
        E_PIN = 1;                      // Clock the command in
        DelayFor18TCY();
        E_PIN = 0;
        DelayFor18TCY();
        TRIS_DATA_PORT = 0xff;          // Data port input
#else                                   // 4-bit interface
#ifdef UPPER                            // Upper nibble interface
        TRIS_DATA_PORT &= 0x0f;
        DATA_PORT &= 0x0f;
        DATA_PORT |= cmd&0xf0;
#else                                   // Lower nibble interface
        TRIS_DATA_PORT &= 0xf0;
        DATA_PORT &= 0xf0;
        DATA_PORT |= (cmd>>4)&0x0f;
#endif
        RW_PIN = 0;                     // Set control signals for command
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock command in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                            // Upper nibble interface
        DATA_PORT &= 0x0f;
        DATA_PORT |= (cmd<<4)&0xf0;
#else                                   // Lower nibble interface
        DATA_PORT &= 0xf0;
        DATA_PORT |= cmd&0x0f;
#endif
        DelayFor18TCY();
        E_PIN = 1;                      // Clock command in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                            // Make data nibble input
        TRIS_DATA_PORT |= 0xf0;
#else
        TRIS_DATA_PORT |= 0x0f;
#endif
#endif
        return;
}

/********************************************************************
*       Function Name:  SetDDRamAddr                                *
*       Return Value:   void                                        *
*       Parameters:     CGaddr: display data address                *
*       Description:    This routine sets the display data address  *
*                       of the Hitachi HD44780 LCD controller. The  *
*                       user must check to see if the LCD controller*
*                       is busy before calling this routine.        *
********************************************************************/
void SetDDRamAddr(unsigned char DDaddr)
{
#ifdef BIT8                                     // 8-bit interface
        TRIS_DATA_PORT = 0;                     // Make port output
        DATA_PORT = DDaddr | 0b10000000;        // Write cmd and address to port
        RW_PIN = 0;                             // Set the control bits
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                              // Clock the cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
        DelayFor18TCY();
        TRIS_DATA_PORT = 0xff;                  // Make port input
#else                                           // 4-bit interface
#ifdef UPPER                                    // Upper nibble  interface
        TRIS_DATA_PORT &= 0x0f;                 // Make port output
        DATA_PORT &= 0x0f;                      // and write upper nibble
        DATA_PORT |= ((DDaddr | 0b10000000) & 0xf0);
#else                                           // Lower nibble interface
        TRIS_DATA_PORT &= 0xf0;                 // Make port output
        DATA_PORT &= 0xf0;                      // and write upper nibble
        DATA_PORT |= (((DDaddr | 0b10000000)>>4) & 0x0f);
#endif
        RW_PIN = 0;                             // Set control bits
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                              // Clock the cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                                    // Upper nibble interface
        DATA_PORT &= 0x0f;                      // Write lower nibble
        DATA_PORT |= ((DDaddr<<4)&0xf0);
#else                                           // Lower nibble interface
        DATA_PORT &= 0xf0;                      // Write lower nibble
        DATA_PORT |= (DDaddr&0x0f);
#endif
        DelayFor18TCY();
        E_PIN = 1;                              // Clock the cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                                    // Upper nibble interface
        TRIS_DATA_PORT |= 0xf0;                 // Make port input
#else                                           // Lower nibble interface
        TRIS_DATA_PORT |= 0x0f;                 // Make port input
#endif
#endif
        return;
}

/********************************************************************
*       Function Name:  SetCGRamAddr                                *
*       Return Value:   void                                        *
*       Parameters:     CGaddr: character generator ram address     *
*       Description:    This routine sets the character generator   *
*                       address of the Hitachi HD44780 LCD          *
*                       controller. The user must check to see if   *
*                       the LCD controller is busy before calling   *
*                       this routine.                               *
********************************************************************/
void SetCGRamAddr(unsigned char CGaddr)
{
#ifdef BIT8                                     // 8-bit interface
        TRIS_DATA_PORT = 0;                     // Make data port ouput
        DATA_PORT = CGaddr | 0b01000000;        // Write cmd and address to port
        RW_PIN = 0;                             // Set control signals
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                              // Clock cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
        DelayFor18TCY();
        TRIS_DATA_PORT = 0xff;                  // Make data port inputs
#else                                           // 4-bit interface
#ifdef UPPER                                    // Upper nibble interface
        TRIS_DATA_PORT &= 0x0f;                 // Make nibble input
        DATA_PORT &= 0x0f;                      // and write upper nibble
        DATA_PORT |= ((CGaddr | 0b01000000) & 0xf0);
#else                                           // Lower nibble interface
        TRIS_DATA_PORT &= 0xf0;                 // Make nibble input
        DATA_PORT &= 0xf0;                      // and write upper nibble
        DATA_PORT |= (((CGaddr |0b01000000)>>4) & 0x0f);
#endif
        RW_PIN = 0;                             // Set control signals
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                              // Clock cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                                    // Upper nibble interface
        DATA_PORT &= 0x0f;                      // Write lower nibble
        DATA_PORT |= ((CGaddr<<4)&0xf0);
#else                                           // Lower nibble interface
        DATA_PORT &= 0xf0;                      // Write lower nibble
        DATA_PORT |= (CGaddr&0x0f);
#endif
        DelayFor18TCY();
        E_PIN = 1;                              // Clock cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                                    // Upper nibble interface
        TRIS_DATA_PORT |= 0xf0;                 // Make inputs
#else                                           // Lower nibble interface
        TRIS_DATA_PORT |= 0x0f;                 // Make inputs
#endif
#endif
        return;
}

/********************************************************************
*       Function Name:  ReadDataXLCD                                *
*       Return Value:   char: data byte from LCD controller         *
*       Parameters:     void                                        *
*       Description:    This routine reads a data byte from the     *
*                       Hitachi HD44780 LCD controller. The user    *
*                       must check to see if the LCD controller is  *
*                       busy before calling this routine. The data  *
*                       is read from the character generator RAM or *
*                       the display data RAM depending on what the  *
*                       previous SetxxRamAddr routine was called.   *
********************************************************************/
char ReadDataXLCD(void)
{
        char data;

#ifdef BIT8                             // 8-bit interface
        RS_PIN = 1;                     // Set the control bits
        RW_PIN = 1;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock the data out of the LCD
        DelayFor18TCY();
        data = DATA_PORT;               // Read the data
        E_PIN = 0;
        RS_PIN = 0;                     // Reset the control bits
        RW_PIN = 0;
#else                                   // 4-bit interface
        RW_PIN = 1;
        RS_PIN = 1;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock the data out of the LCD
        DelayFor18TCY();
#ifdef UPPER                            // Upper nibble interface
        data = DATA_PORT&0xf0;          // Read the upper nibble of data
#else                                   // Lower nibble interface
        data = (DATA_PORT<<4)&0xf0;     // read the upper nibble of data
#endif
        E_PIN = 0;                      // Reset the clock line
        DelayFor18TCY();
        E_PIN = 1;                      // Clock the next nibble out of the LCD
        DelayFor18TCY();
#ifdef UPPER                            // Upper nibble interface
        data |= (DATA_PORT>>4)&0x0f;    // Read the lower nibble of data
#else                                   // Lower nibble interface
        data |= DATA_PORT&0x0f;         // Read the lower nibble of data
#endif
        E_PIN = 0;                                      
        RS_PIN = 0;                     // Reset the control bits
        RW_PIN = 0;
#endif
        return(data);                   // Return the data byte
}

/*********************************************************************
*       Function Name:  ReadAddrXLCD                                 *
*       Return Value:   char: address from LCD controller            *
*       Parameters:     void                                         *
*       Description:    This routine reads an address byte from the  *
*                       Hitachi HD44780 LCD controller. The user     *
*                       must check to see if the LCD controller is   *
*                       busy before calling this routine. The address*
*                       is read from the character generator RAM or  *
*                       the display data RAM depending on what the   *
*                       previous SetxxRamAddr routine was called.    *
*********************************************************************/
unsigned char ReadAddrXLCD(void)
{
        char data;                      // Holds the data retrieved from the LCD

#ifdef BIT8                             // 8-bit interface
        RW_PIN = 1;                     // Set control bits for the read
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock data out of the LCD controller
        DelayFor18TCY();
        data = DATA_PORT;               // Save the data in the register
        E_PIN = 0;
        RW_PIN = 0;                     // Reset the control bits
#else                                   // 4-bit interface
        RW_PIN = 1;                     // Set control bits for the read
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock data out of the LCD controller
        DelayFor18TCY();
#ifdef UPPER                            // Upper nibble interface
        data = DATA_PORT&0xf0;          // Read the nibble into the upper nibble of data
#else                                   // Lower nibble interface
        data = (DATA_PORT<<4)&0xf0;     // Read the nibble into the upper nibble of data
#endif
        E_PIN = 0;                      // Reset the clock
        DelayFor18TCY();
        E_PIN = 1;                      // Clock out the lower nibble
        DelayFor18TCY();
#ifdef UPPER                            // Upper nibble interface
        data |= (DATA_PORT>>4)&0x0f;    // Read the nibble into the lower nibble of data
#else                                   // Lower nibble interface
        data |= DATA_PORT&0x0f;         // Read the nibble into the lower nibble of data
#endif
        E_PIN = 0;
        RW_PIN = 0;                     // Reset the control lines
#endif
        return (data&0x7f);             // Return the address, Mask off the busy bit
}

/********************************************************************
*       Function Name:  putsXLCD
*       Return Value:   void
*       Parameters:     buffer: pointer to string
*       Description:    This routine writes a string of bytes to the
*                       Hitachi HD44780 LCD controller. The user
*                       must check to see if the LCD controller is
*                       busy before calling this routine. The data
*                       is written to the character generator RAM or
*                       the display data RAM depending on what the
*                       previous SetxxRamAddr routine was called.
********************************************************************/
void putsXLCD(char *buffer)
{
        while(*buffer)                  // Write data to LCD up to null
        {
                while(BusyXLCD());      // Wait while LCD is busy
                WriteDataXLCD(*buffer); // Write character to LCD
                buffer++;               // Increment buffer
        }
        return;
}

/********************************************************************
*       Function Name:  putrsXLCD
*       Return Value:   void
*       Parameters:     buffer: pointer to string
*       Description:    This routine writes a string of bytes to the
*                       Hitachi HD44780 LCD controller. The user
*                       must check to see if the LCD controller is
*                       busy before calling this routine. The data
*                       is written to the character generator RAM or
*                       the display data RAM depending on what the
*                       previous SetxxRamAddr routine was called.
********************************************************************/
void putrsXLCD(const  char *buffer)
{
        while(*buffer)                  // Write data to LCD up to null
        {
                while(BusyXLCD());      // Wait while LCD is busy
                WriteDataXLCD(*buffer); // Write character to LCD
                buffer++;               // Increment buffer
        }
        return;
}

/********************************************************************
*       Function Name:  BusyXLCD                                    *
*       Return Value:   char: busy status of LCD controller         *
*       Parameters:     void                                        *
*       Description:    This routine reads the busy status of the   *
*                       Hitachi HD44780 LCD controller.             *
********************************************************************/
unsigned char BusyXLCD(void)
{
#ifdef BUSY_LCD
        RW_PIN = 1;                     // Set the control bits for read
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock in the command
        DelayFor18TCY();
#ifdef BIT8                             // 8-bit interface
        if(DATA_PORT&0x80)                      // Read bit 7 (busy bit)
        {                               // If high
                E_PIN = 0;              // Reset clock line
                RW_PIN = 0;             // Reset control line
                return 1;               // Return TRUE
        }
        else                            // Bit 7 low
        {
                E_PIN = 0;              // Reset clock line
                RW_PIN = 0;             // Reset control line
                return 0;               // Return FALSE
        }
#else                                   // 4-bit interface
#ifdef UPPER                            // Upper nibble interface
        if(DATA_PORT&0x80)
#else                                   // Lower nibble interface
        if(DATA_PORT&0x08)
#endif
        {
                E_PIN = 0;              // Reset clock line
                DelayFor18TCY();
                E_PIN = 1;              // Clock out other nibble
                DelayFor18TCY();
                E_PIN = 0;
                RW_PIN = 0;             // Reset control line
                return 1;               // Return TRUE
        }
        else                            // Busy bit is low
        {
                E_PIN = 0;              // Reset clock line
                DelayFor18TCY();
                E_PIN = 1;              // Clock out other nibble
                DelayFor18TCY();
                E_PIN = 0;
                RW_PIN = 0;             // Reset control line
                return 0;               // Return FALSE
        }
#endif
#else
        __delay_ms(5);
        return 0;
#endif

}



PIC16F819 Configuration Bit Settings


Código: [Seleccionar]
// PIC16F819 Configuration Bit Settings

#include <xc.h>

// CONFIG
#pragma config FOSC = INTOSCCLK // Oscillator Selection bits (INTRC oscillator; CLKO function on RA6/OSC2/CLKO pin and port I/O function on RA7/OSC1/CLKI pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF       // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
#pragma config BOREN = OFF       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF      // Low-Voltage Programming Enable bit (RB3/PGM pin has PGM function, Low-Voltage Programming enabled)
#pragma config CPD = OFF        // Data EE Memory Code Protection bit (Code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off)
#pragma config CCPMX = RB2      // CCP1 Pin Selection bit (CCP1 function on RB2)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

// CONFIG2
//#pragma config BOR4V = BOR40V   // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF        // Flash Program Memory Self Write Enable





« Última modificación: 21 de Mayo de 2013, 15:02:06 por Rseliman »
Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Mini curso "Programación en XC8"
« Respuesta #27 en: 21 de Mayo de 2013, 15:16:11 »
Bueno logre hacerlo andar en el PORT A les paso las modificaciones en main y libreria ....para que funcione en mi proteus le comento las lineas del main que lo ponen en 4 mHZ ...no se porque ...pero eso solo pasa en el proteus

Saludos ....adjunto tambien el archivo proteus modificado al PORTA...de esta manera me quedan disponibles los pines de I2C que nesecitaba


Gracias





Main.c
Código: [Seleccionar]
#include <xc.h>
#define _XTAL_FREQ 4000000
#include <stdio.h>
#include <stdlib.h>
#include "lcd_pic16.c"
#include "delay.h"

// PIC16F819 Configuration Bit Settings





//variables globales
unsigned char buffer [14];
// unsigned int contador=0;
//funciones prototipo
void init(void);






void main(void)
{
   //OSCCONbits.IRCF2 = 1; //
   //OSCCONbits.IRCF1 = 1; // defino oscilador interno en 4 mhz
   //OSCCONbits.IRCF0 = 0; //
 
    
    init(); // inicio lcd

while(1)

{
                SetDDRamAddr(0x00);
putrsXLCD("Ramiro Seliman");
                putsXLCD(buffer);
                SetDDRamAddr(0x40);
putrsXLCD("Victoria E.R");
              

}
}
void init(void)
{
    ADCON0bits.ADON = 0;
    ADCON1bits.PCFG3 = 0;
    ADCON1bits.PCFG2 = 1;
    ADCON1bits.PCFG1 = 1;
    ADCON1bits.PCFG0 = 1;
    ADCON1bits.ADCS2 = 0;

    
    TRISB=0;    //todo el PORTb como salidas digitales
    PORTB=0;
   // TRISA=0;
   // PORTA=0;
    OpenXLCD(FOUR_BIT & LINES_5X7 );
}

lcd_pic16.c

Código: [Seleccionar]
//*
 *
 *   Notes:
 *      - These libraries routines are written to support the
 *        Hitachi HD44780 LCD controller.
 *      - The user must define the following items:
 *          - The LCD interface type (4- or 8-bits)
 *          - If 4-bit mode
 *              - whether using the upper or lower nibble
 *          - The data port
 *              - The tris register for data port
 *              - The control signal ports and pins
 *              - The control signal port tris and pins
 *          - The user must provide three delay routines:
 *              - DelayFor18TCY() provides a 18 Tcy delay
 *              - DelayPORXLCD() provides at least 15ms delay
 *              - DelayXLCD() provides at least 5ms delay
 */

/* Interface type 8-bit or 4-bit
 * For 8-bit operation uncomment the #define BIT8
 */
// #define BIT8

/* When in 4-bit interface define if the data is in the upper
 * or lower nibble.  For lower nibble, comment the #define UPPER
 */

//#define UPPER

/* When in 6-10-bit interface comment the #define BUSY_LCD and conected PIN
 * R/W to GND in LCD
 */
 #define BUSY_LCD

/* DATA_PORT defines the port to which the LCD data lines are connected */
 #define DATA_PORT       PORTA
 #define TRIS_DATA_PORT TRISA

/* CTRL_PORT defines the port where the control lines are connected.
 * These are just samples, change to match your application.
 */
 #define RW_PIN   PORTAbits.RA6   /* PORT for RW */
 #define TRIS_RW  TRISAbits.TRISA6   /* TRIS for RW */

 #define RS_PIN   PORTAbits.RA7   /* PORT for RS */
 #define TRIS_RS  TRISAbits.TRISA7     /* TRIS for RS */

 #define E_PIN    PORTAbits.RA4 /* PORT for D  */
 #define TRIS_E   TRISAbits.TRISA4     /* TRIS for E  */

/* Display ON/OFF Control defines */
#define DON         0b00001111  /* Display on      */
#define DOFF        0b00001011  /* Display off     */
#define CURSOR_ON   0b00001111  /* Cursor on       */
#define CURSOR_OFF  0b00001101  /* Cursor off      */
#define BLINK_ON    0b00001111  /* Cursor Blink    */
#define BLINK_OFF   0b00001110  /* Cursor No Blink */

/* Cursor or Display Shift defines */
#define SHIFT_CUR_LEFT    0b00000100  /* Cursor shifts to the left   */
#define SHIFT_CUR_RIGHT   0b00000101  /* Cursor shifts to the right  */
#define SHIFT_DISP_LEFT   0b00000110  /* Display shifts to the left  */
#define SHIFT_DISP_RIGHT  0b00000111  /* Display shifts to the right */

/* Function Set defines */
#define FOUR_BIT   0b00101100  /* 4-bit Interface               */
#define EIGHT_BIT  0b00111100  /* 8-bit Interface               */
#define LINE_5X7   0b00110000  /* 5x7 characters, single line   */
#define LINE_5X10  0b00110100  /* 5x10 characters               */
#define LINES_5X7  0b00111000  /* 5x7 characters, multiple line */

#ifdef _OMNI_CODE_
#define PARAM_SCLASS
#else
#define PARAM_SCLASS auto
#endif

/* CLS_Line2
 * Clear Screen Line 2
 */
void CLS_Line2(void);

/* CLS_Line1
 * Clear Screen Line 1
 */
void CLS_Line1(void);
/* OpenXLCD
 * Configures I/O pins for external LCD
 */
void OpenXLCD(PARAM_SCLASS unsigned char);

/* SetCGRamAddr
 * Sets the character generator address
 */
void SetCGRamAddr(PARAM_SCLASS unsigned char);

/* SetDDRamAddr
 * Sets the display data address
 */
void SetDDRamAddr(PARAM_SCLASS unsigned char);

/* BusyXLCD
 * Returns the busy status of the LCD
 */
unsigned char BusyXLCD(void);

/* ReadAddrXLCD
 * Reads the current address
 */
unsigned char ReadAddrXLCD(void);

/* ReadDataXLCD
 * Reads a byte of data
 */
char ReadDataXLCD(void);

/* WriteCmdXLCD
 * Writes a command to the LCD
 */
void WriteCmdXLCD(PARAM_SCLASS unsigned char);

/* WriteDataXLCD
 * Writes a data byte to the LCD
 */
void WriteDataXLCD(PARAM_SCLASS char);

/* putcXLCD
 * A putc is a write
 */
#define putcXLCD WriteDataXLCD

/* putsXLCD
 * Writes a string of characters to the LCD
 */
void putsXLCD(PARAM_SCLASS char *);

/* putrsXLCD
 * Writes a string of characters in  to the LCD
 */
void putrsXLCD(const char *);

// Rutinas de tiempo auxiliares para la libreria XLCD
void DelayFor18TCY(void)
{
__delay_us(18);
}

void DelayPORXLCD(void)
{
__delay_ms(20); //Delay de 15 ms
}

void DelayXLCD(void)
{
__delay_ms(20); //Delay de 20 ms
}

void CLS_Line2(void)
{
    SetDDRamAddr(0x40);
    putrsXLCD("                ");
}

void CLS_Line1(void)
{
    SetDDRamAddr(0x00);
    putrsXLCD("                ");
}
/********************************************************************
*       Function Name:  OpenXLCD                                    *
*       Return Value:   void                                        *
*       Parameters:     lcdtype: sets the type of LCD (lines)       *
*       Description:    This routine configures the LCD. Based on   *
*                       the Hitachi HD44780 LCD controller. The     *
*                       routine will configure the I/O pins of the  *
*                       microcontroller, setup the LCD for 4- or    *
*                       8-bit mode and clear the display. The user  *
*                       must provide three delay routines:          *
*                       DelayFor18TCY() provides a 18 Tcy delay     *
*                       DelayPORXLCD() provides at least 15ms delay *
*                       DelayXLCD() provides at least 5ms delay     *
********************************************************************/
void OpenXLCD(unsigned char lcdtype)
{
        // The data bits must be either a 8-bit port or the upper or
        // lower 4-bits of a port. These pins are made into inputs
#ifdef BIT8                             // 8-bit mode, use whole port
        DATA_PORT = 0;
        TRIS_DATA_PORT = 0x00;
#else                                   // 4-bit mode
#ifdef UPPER                            // Upper 4-bits of the port
        DATA_PORT &= 0x0f;
        TRIS_DATA_PORT &= 0x0F;
#else                                   // Lower 4-bits of the port
        DATA_PORT &= 0xf0;
        TRIS_DATA_PORT &= 0xF0;
#endif
#endif
        TRIS_RW = 0;                    // All control signals made outputs
        TRIS_RS = 0;
        TRIS_E = 0;
        RW_PIN = 0;                     // R/W pin made low
        RS_PIN = 0;                     // Register select pin made low
        E_PIN = 0;                      // Clock pin made low

        // Delay for 15ms to allow for LCD Power on reset
        DelayPORXLCD();
 //-------------------reset procedure through software----------------------      
WriteCmdXLCD(0x30);
__delay_ms(5);

WriteCmdXLCD(0x30);
__delay_ms(1);


WriteCmdXLCD(0x32);
while( BusyXLCD() );
//------------------------------------------------------------------------------------------


        // Set data interface width, # lines, font
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(lcdtype);          // Function set cmd

        // Turn the display on then off
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(DOFF&CURSOR_OFF&BLINK_OFF);        // Display OFF/Blink OFF
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(DON&CURSOR_ON&BLINK_ON);           // Display ON/Blink ON

        // Clear display
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(0x01);             // Clear display

        // Set entry mode inc, no shift
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(SHIFT_CUR_RIGHT);   // Entry Mode
 
while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(0x06);   // Incremente
 
        while(BusyXLCD());              // Wait if LCD busy
        SetDDRamAddr(0x80);             // Set Display data ram address to 0
        
        while(BusyXLCD());              // Wait if LCD busy
        WriteCmdXLCD(CURSOR_OFF);       // Cursor OFF
        return;
}


/********************************************************************
*       Function Name:  WriteDataXLCD                               *
*       Return Value:   void                                        *
*       Parameters:     data: data byte to be written to LCD        *
*       Description:    This routine writes a data byte to the      *
*                       Hitachi HD44780 LCD controller. The user    *
*                       must check to see if the LCD controller is  *
*                       busy before calling this routine. The data  *
*                       is written to the character generator RAM or*
*                       the display data RAM depending on what the  *
*                       previous SetxxRamAddr routine was called.   *
********************************************************************/
void WriteDataXLCD(char data)
{
#ifdef BIT8                             // 8-bit interface
        TRIS_DATA_PORT = 0;             // Make port output
        DATA_PORT = data;               // Write data to port
        RS_PIN = 1;                     // Set control bits
        RW_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock data into LCD
        DelayFor18TCY();
        E_PIN = 0;
        RS_PIN = 0;                     // Reset control bits
        TRIS_DATA_PORT = 0xff;          // Make port input
#else                                   // 4-bit interface
#ifdef UPPER                            // Upper nibble interface
        TRIS_DATA_PORT &= 0x0f;
        DATA_PORT &= 0x0f;
        DATA_PORT |= data&0xf0;
#else                                   // Lower nibble interface
        TRIS_DATA_PORT &= 0xf0;
        DATA_PORT &= 0xf0;
        DATA_PORT |= ((data>>4)&0x0f);
#endif
        RS_PIN = 1;                     // Set control bits
        RW_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock nibble into LCD
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                            // Upper nibble interface
        DATA_PORT &= 0x0f;
        DATA_PORT |= ((data<<4)&0xf0);
#else                                   // Lower nibble interface
        DATA_PORT &= 0xf0;
        DATA_PORT |= (data&0x0f);
#endif
        DelayFor18TCY();
        E_PIN = 1;                      // Clock nibble into LCD
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                            // Upper nibble interface
        TRIS_DATA_PORT |= 0xf0;
#else                                   // Lower nibble interface
        TRIS_DATA_PORT |= 0x0f;
#endif
#endif
        return;
}

/********************************************************************
*       Function Name:  WriteCmdXLCD                                *
*       Return Value:   void                                        *
*       Parameters:     cmd: command to send to LCD                 *
*       Description:    This routine writes a command to the Hitachi*
*                       HD44780 LCD controller. The user must check *
*                       to see if the LCD controller is busy before *
*                       calling this routine.                       *
********************************************************************/
void WriteCmdXLCD(unsigned char cmd)
{
#ifdef BIT8                             // 8-bit interface
        TRIS_DATA_PORT = 0;             // Data port output
        DATA_PORT = cmd;                // Write command to data port
        RW_PIN = 0;                     // Set the control signals
        RS_PIN = 0;                     // for sending a command
        DelayFor18TCY();
        E_PIN = 1;                      // Clock the command in
        DelayFor18TCY();
        E_PIN = 0;
        DelayFor18TCY();
        TRIS_DATA_PORT = 0xff;          // Data port input
#else                                   // 4-bit interface
#ifdef UPPER                            // Upper nibble interface
        TRIS_DATA_PORT &= 0x0f;
        DATA_PORT &= 0x0f;
        DATA_PORT |= cmd&0xf0;
#else                                   // Lower nibble interface
        TRIS_DATA_PORT &= 0xf0;
        DATA_PORT &= 0xf0;
        DATA_PORT |= (cmd>>4)&0x0f;
#endif
        RW_PIN = 0;                     // Set control signals for command
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock command in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                            // Upper nibble interface
        DATA_PORT &= 0x0f;
        DATA_PORT |= (cmd<<4)&0xf0;
#else                                   // Lower nibble interface
        DATA_PORT &= 0xf0;
        DATA_PORT |= cmd&0x0f;
#endif
        DelayFor18TCY();
        E_PIN = 1;                      // Clock command in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                            // Make data nibble input
        TRIS_DATA_PORT |= 0xf0;
#else
        TRIS_DATA_PORT |= 0x0f;
#endif
#endif
        return;
}

/********************************************************************
*       Function Name:  SetDDRamAddr                                *
*       Return Value:   void                                        *
*       Parameters:     CGaddr: display data address                *
*       Description:    This routine sets the display data address  *
*                       of the Hitachi HD44780 LCD controller. The  *
*                       user must check to see if the LCD controller*
*                       is busy before calling this routine.        *
********************************************************************/
void SetDDRamAddr(unsigned char DDaddr)
{
#ifdef BIT8                                     // 8-bit interface
        TRIS_DATA_PORT = 0;                     // Make port output
        DATA_PORT = DDaddr | 0b10000000;        // Write cmd and address to port
        RW_PIN = 0;                             // Set the control bits
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                              // Clock the cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
        DelayFor18TCY();
        TRIS_DATA_PORT = 0xff;                  // Make port input
#else                                           // 4-bit interface
#ifdef UPPER                                    // Upper nibble  interface
        TRIS_DATA_PORT &= 0x0f;                 // Make port output
        DATA_PORT &= 0x0f;                      // and write upper nibble
        DATA_PORT |= ((DDaddr | 0b10000000) & 0xf0);
#else                                           // Lower nibble interface
        TRIS_DATA_PORT &= 0xf0;                 // Make port output
        DATA_PORT &= 0xf0;                      // and write upper nibble
        DATA_PORT |= (((DDaddr | 0b10000000)>>4) & 0x0f);
#endif
        RW_PIN = 0;                             // Set control bits
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                              // Clock the cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                                    // Upper nibble interface
        DATA_PORT &= 0x0f;                      // Write lower nibble
        DATA_PORT |= ((DDaddr<<4)&0xf0);
#else                                           // Lower nibble interface
        DATA_PORT &= 0xf0;                      // Write lower nibble
        DATA_PORT |= (DDaddr&0x0f);
#endif
        DelayFor18TCY();
        E_PIN = 1;                              // Clock the cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                                    // Upper nibble interface
        TRIS_DATA_PORT |= 0xf0;                 // Make port input
#else                                           // Lower nibble interface
        TRIS_DATA_PORT |= 0x0f;                 // Make port input
#endif
#endif
        return;
}

/********************************************************************
*       Function Name:  SetCGRamAddr                                *
*       Return Value:   void                                        *
*       Parameters:     CGaddr: character generator ram address     *
*       Description:    This routine sets the character generator   *
*                       address of the Hitachi HD44780 LCD          *
*                       controller. The user must check to see if   *
*                       the LCD controller is busy before calling   *
*                       this routine.                               *
********************************************************************/
void SetCGRamAddr(unsigned char CGaddr)
{
#ifdef BIT8                                     // 8-bit interface
        TRIS_DATA_PORT = 0;                     // Make data port ouput
        DATA_PORT = CGaddr | 0b01000000;        // Write cmd and address to port
        RW_PIN = 0;                             // Set control signals
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                              // Clock cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
        DelayFor18TCY();
        TRIS_DATA_PORT = 0xff;                  // Make data port inputs
#else                                           // 4-bit interface
#ifdef UPPER                                    // Upper nibble interface
        TRIS_DATA_PORT &= 0x0f;                 // Make nibble input
        DATA_PORT &= 0x0f;                      // and write upper nibble
        DATA_PORT |= ((CGaddr | 0b01000000) & 0xf0);
#else                                           // Lower nibble interface
        TRIS_DATA_PORT &= 0xf0;                 // Make nibble input
        DATA_PORT &= 0xf0;                      // and write upper nibble
        DATA_PORT |= (((CGaddr |0b01000000)>>4) & 0x0f);
#endif
        RW_PIN = 0;                             // Set control signals
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                              // Clock cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                                    // Upper nibble interface
        DATA_PORT &= 0x0f;                      // Write lower nibble
        DATA_PORT |= ((CGaddr<<4)&0xf0);
#else                                           // Lower nibble interface
        DATA_PORT &= 0xf0;                      // Write lower nibble
        DATA_PORT |= (CGaddr&0x0f);
#endif
        DelayFor18TCY();
        E_PIN = 1;                              // Clock cmd and address in
        DelayFor18TCY();
        E_PIN = 0;
#ifdef UPPER                                    // Upper nibble interface
        TRIS_DATA_PORT |= 0xf0;                 // Make inputs
#else                                           // Lower nibble interface
        TRIS_DATA_PORT |= 0x0f;                 // Make inputs
#endif
#endif
        return;
}

/********************************************************************
*       Function Name:  ReadDataXLCD                                *
*       Return Value:   char: data byte from LCD controller         *
*       Parameters:     void                                        *
*       Description:    This routine reads a data byte from the     *
*                       Hitachi HD44780 LCD controller. The user    *
*                       must check to see if the LCD controller is  *
*                       busy before calling this routine. The data  *
*                       is read from the character generator RAM or *
*                       the display data RAM depending on what the  *
*                       previous SetxxRamAddr routine was called.   *
********************************************************************/
char ReadDataXLCD(void)
{
        char data;

#ifdef BIT8                             // 8-bit interface
        RS_PIN = 1;                     // Set the control bits
        RW_PIN = 1;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock the data out of the LCD
        DelayFor18TCY();
        data = DATA_PORT;               // Read the data
        E_PIN = 0;
        RS_PIN = 0;                     // Reset the control bits
        RW_PIN = 0;
#else                                   // 4-bit interface
        RW_PIN = 1;
        RS_PIN = 1;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock the data out of the LCD
        DelayFor18TCY();
#ifdef UPPER                            // Upper nibble interface
        data = DATA_PORT&0xf0;          // Read the upper nibble of data
#else                                   // Lower nibble interface
        data = (DATA_PORT<<4)&0xf0;     // read the upper nibble of data
#endif
        E_PIN = 0;                      // Reset the clock line
        DelayFor18TCY();
        E_PIN = 1;                      // Clock the next nibble out of the LCD
        DelayFor18TCY();
#ifdef UPPER                            // Upper nibble interface
        data |= (DATA_PORT>>4)&0x0f;    // Read the lower nibble of data
#else                                   // Lower nibble interface
        data |= DATA_PORT&0x0f;         // Read the lower nibble of data
#endif
        E_PIN = 0;                                      
        RS_PIN = 0;                     // Reset the control bits
        RW_PIN = 0;
#endif
        return(data);                   // Return the data byte
}

/*********************************************************************
*       Function Name:  ReadAddrXLCD                                 *
*       Return Value:   char: address from LCD controller            *
*       Parameters:     void                                         *
*       Description:    This routine reads an address byte from the  *
*                       Hitachi HD44780 LCD controller. The user     *
*                       must check to see if the LCD controller is   *
*                       busy before calling this routine. The address*
*                       is read from the character generator RAM or  *
*                       the display data RAM depending on what the   *
*                       previous SetxxRamAddr routine was called.    *
*********************************************************************/
unsigned char ReadAddrXLCD(void)
{
        char data;                      // Holds the data retrieved from the LCD

#ifdef BIT8                             // 8-bit interface
        RW_PIN = 1;                     // Set control bits for the read
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock data out of the LCD controller
        DelayFor18TCY();
        data = DATA_PORT;               // Save the data in the register
        E_PIN = 0;
        RW_PIN = 0;                     // Reset the control bits
#else                                   // 4-bit interface
        RW_PIN = 1;                     // Set control bits for the read
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock data out of the LCD controller
        DelayFor18TCY();
#ifdef UPPER                            // Upper nibble interface
        data = DATA_PORT&0xf0;          // Read the nibble into the upper nibble of data
#else                                   // Lower nibble interface
        data = (DATA_PORT<<4)&0xf0;     // Read the nibble into the upper nibble of data
#endif
        E_PIN = 0;                      // Reset the clock
        DelayFor18TCY();
        E_PIN = 1;                      // Clock out the lower nibble
        DelayFor18TCY();
#ifdef UPPER                            // Upper nibble interface
        data |= (DATA_PORT>>4)&0x0f;    // Read the nibble into the lower nibble of data
#else                                   // Lower nibble interface
        data |= DATA_PORT&0x0f;         // Read the nibble into the lower nibble of data
#endif
        E_PIN = 0;
        RW_PIN = 0;                     // Reset the control lines
#endif
        return (data&0x7f);             // Return the address, Mask off the busy bit
}

/********************************************************************
*       Function Name:  putsXLCD
*       Return Value:   void
*       Parameters:     buffer: pointer to string
*       Description:    This routine writes a string of bytes to the
*                       Hitachi HD44780 LCD controller. The user
*                       must check to see if the LCD controller is
*                       busy before calling this routine. The data
*                       is written to the character generator RAM or
*                       the display data RAM depending on what the
*                       previous SetxxRamAddr routine was called.
********************************************************************/
void putsXLCD(char *buffer)
{
        while(*buffer)                  // Write data to LCD up to null
        {
                while(BusyXLCD());      // Wait while LCD is busy
                WriteDataXLCD(*buffer); // Write character to LCD
                buffer++;               // Increment buffer
        }
        return;
}

/********************************************************************
*       Function Name:  putrsXLCD
*       Return Value:   void
*       Parameters:     buffer: pointer to string
*       Description:    This routine writes a string of bytes to the
*                       Hitachi HD44780 LCD controller. The user
*                       must check to see if the LCD controller is
*                       busy before calling this routine. The data
*                       is written to the character generator RAM or
*                       the display data RAM depending on what the
*                       previous SetxxRamAddr routine was called.
********************************************************************/
void putrsXLCD(const  char *buffer)
{
        while(*buffer)                  // Write data to LCD up to null
        {
                while(BusyXLCD());      // Wait while LCD is busy
                WriteDataXLCD(*buffer); // Write character to LCD
                buffer++;               // Increment buffer
        }
        return;
}

/********************************************************************
*       Function Name:  BusyXLCD                                    *
*       Return Value:   char: busy status of LCD controller         *
*       Parameters:     void                                        *
*       Description:    This routine reads the busy status of the   *
*                       Hitachi HD44780 LCD controller.             *
********************************************************************/
unsigned char BusyXLCD(void)
{
#ifdef BUSY_LCD
        RW_PIN = 1;                     // Set the control bits for read
        RS_PIN = 0;
        DelayFor18TCY();
        E_PIN = 1;                      // Clock in the command
        DelayFor18TCY();
#ifdef BIT8                             // 8-bit interface
        if(DATA_PORT&0x80)                      // Read bit 7 (busy bit)
        {                               // If high
                E_PIN = 0;              // Reset clock line
                RW_PIN = 0;             // Reset control line
                return 1;               // Return TRUE
        }
        else                            // Bit 7 low
        {
                E_PIN = 0;              // Reset clock line
                RW_PIN = 0;             // Reset control line
                return 0;               // Return FALSE
        }
#else                                   // 4-bit interface
#ifdef UPPER                            // Upper nibble interface
        if(DATA_PORT&0x80)
#else                                   // Lower nibble interface
        if(DATA_PORT&0x08)
#endif
        {
                E_PIN = 0;              // Reset clock line
                DelayFor18TCY();
                E_PIN = 1;              // Clock out other nibble
                DelayFor18TCY();
                E_PIN = 0;
                RW_PIN = 0;             // Reset control line
                return 1;               // Return TRUE
        }
        else                            // Busy bit is low
        {
                E_PIN = 0;              // Reset clock line
                DelayFor18TCY();
                E_PIN = 1;              // Clock out other nibble
                DelayFor18TCY();
                E_PIN = 0;
                RW_PIN = 0;             // Reset control line
                return 0;               // Return FALSE
        }
#endif
#else
        __delay_ms(5);
        return 0;
#endif

}




PIC16F819 Configuration Bit Settings


Código: [Seleccionar]
// PIC16F819 Configuration Bit Settings

#include <xc.h>

// CONFIG
#pragma config FOSC = INTOSCCLK // Oscillator Selection bits (INTRC oscillator; CLKO function on RA6/OSC2/CLKO pin and port I/O function on RA7/OSC1/CLKI pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = ON       // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF       // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR)
#pragma config BOREN = OFF       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = OFF      // Low-Voltage Programming Enable bit (RB3/PGM pin has PGM function, Low-Voltage Programming enabled)
#pragma config CPD = OFF        // Data EE Memory Code Protection bit (Code protection off)
#pragma config WRT = OFF        // Flash Program Memory Write Enable bits (Write protection off)
#pragma config CCPMX = RB2      // CCP1 Pin Selection bit (CCP1 function on RB2)
#pragma config CP = OFF         // Flash Program Memory Code Protection bit (Code protection off)

// CONFIG2
//#pragma config BOR4V = BOR40V   // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF        // Flash Program Memory Self Write Enable






[/quote]
« Última modificación: 21 de Mayo de 2013, 15:27:28 por Rseliman »
Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!

Desconectado jukinch

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 608
Re: Mini curso "Programación en XC8"
« Respuesta #28 en: 21 de Mayo de 2013, 18:52:47 »
Rseliman:
         Gracias por compartir.  ((:-)).-
         Poco a poco iremos subiendo más y más ejemplos.
            Saludos.
                  Jukinch
"Divide las dificultades que examinas en tantas partes como sea posible para su mejor solución." -René Descartes

Desconectado Rseliman

  • PIC16
  • ***
  • Mensajes: 239
Re: Mini curso "Programación en XC8"
« Respuesta #29 en: 23 de Mayo de 2013, 14:52:11 »
Rseliman:
         Gracias por compartir.  ((:-)).-
         Poco a poco iremos subiendo más y más ejemplos.
            Saludos.
                  Jukinch


Atento a tu pedido ...subo el proyecto completo ....comenten si les anda por favor ...gracias


Las Grandes Obras las sueñan los grandes locos , mientras los inutiles las critican !!