Attachment 'capitulo4c.sgml'

Download

        <sect1 id="uart2" xreflabel="uart2">
                <title>M&oacute;dulo UART2</title>
                <para> Esta biblioteca nos ayudar&aacute; a convertir n&uacute;meros a binarios a formatos de de texto en representaci&oacute;n DECIMAL y HEXADECIMAL.</para>

                <para>
                <screen>
        #include &lt;uart2.h>
                </screen>
                </para>

                <sect2 id="puth" xreflabel="puth">
                <title>puth</title>
                <para>
                transforma la cifra hexadecimal (medio octeto) en 1 car&aacute;cter ASCII y lo envia.
                </para>
                <para>
                Por ejemplo si tienes el hexadecimal 0x4A y tomas el n&uacute;mero "A" (osea 10 en decimal - 1010 en binario), "puth" lo transforma en el caracter 'A' y lo envia.
                </para>
                <screen>
        Transforma el numero "0" en el caracter '0'.
        Transforma el numero "1" en el caracter '1'.
        Transforma el numero "2" en el caracter '2'.
        ...
        Transforma el numero "A" en el caracter 'A'.
        Transforma el numero "B" en el caracter 'B'.
        ...
        Transforma el numero "F" en el caracter 'F'.
                </screen>
                <para>El caracter generado es enviado usando la funci&oacute;n miputc.</para>
                <screen>
        void puth(void (*miputc)(char),char a);
                </screen>
                </sect2>

                <sect2 id="puthex" xreflabel="puthex">
                <title>puthex</title>
                <para>
                transforma un  n&uacute;mero hexadecimal (un octeto) en 2  caracteres ASCII y lo envia.
                </para>
                <para>
                Por ejemplo, si tienes el hexadecimal 0x4A, puthex toma el n&uacute;mero "4" lo transforma en el caracter '4' y lo envia con miputc, toma el numero "A"  lo transforma en el caracter 'A' y lo envia con miputc.
                </para>
                <para>
                <screen>
        0x4A    =>      miputc('4');
                        miputc('A');
                </screen>
                </para>
                <para>
                <screen>
        void puthex(void (*miputc)(char),char nb);
                </screen>
                </para>
                </sect2>

                <sect2 id="putint" xreflabel="putint">
                <title>putint</title>
                <para>
                transforma un  n&uacute;mero entero de 16 bit en su representaci&oacute;n hexadecimal de 4 caracteres ASCII y luego los envia uno por uno.
                </para>
                <para>
                Por ejemplo, si tienes el n&uacute;mero 1030, putint lo transforma en su representaci&oacute;n en HEXADECIMAL "0x0406", putint toma '0','4','0','6' y los envia con miputc.
                </para>
                <screen>
        1030 => 0x0406  =>      miputc('0');
                                miputc('4');
                                miputc('0');
                                miputc('6');
                </screen>
                <screen>
        void putint(void (*miputc)(char),int num);
                </screen>
                </sect2>

                <sect2 id="geth" xreflabel="geth">
                <title>geth</title>
                <para>
                Lee un car&aacute;cter ASCII y lo transforma en una cifra hexadecimal.
                </para>
                <para>
                Por ejemplo si lees el caracter "A" , "geth" lo transforma en el numero 10 en decimal codificado en binario BCD.
                </para>
                <screen>
        Transforma el caracter '0' en el n&uacute;mero 0.
        Transforma el caracter '1' en el n&uacute;mero 1.
        Transforma el caracter '2' en el n&uacute;mero 2.
        ...
        Transforma el caracter 'a' &oacute; 'A' en el n&uacute;mero 10 (0x0a).
        Transforma el caracter 'b' &oacute; 'B' en el n&uacute;mero 11 (0x0b).
        ...
        Transforma el caracter 'f' &oacute; 'F' en el n&uacute;mero 15 (0x0f).

        //cualquier otro numero se convierte 0xff
                </screen>
                <para>Para obtener el caracter se utiliza la funci&oacute;n migetc.</para>
                <screen>
        char geth(char (*migetc)(void));
                </screen>
                </sect2>

                <sect2 id="gethex" xreflabel="gethex">
                <title>gethex</title>
                <para>
                Lee 2 caracteres ASCII y transforma en número hexadecimal.
                </para>
                <para>
                Por ejemplo, si tienes dos caracteres ASCII como "4" y "A", gethex toma el caracter "4" y lo transforma en el n&uacute;mero 0x40 y toma el caracter "A" y lo transforma en el n&uacute;mero 0x0A luego los une en 0x4A.
                </para>
                <para>
                <screen>
        miputc('4');
        miputc('A');    =>      0x4A
                </screen>
                </para>
                <para>
                <screen>
        char gethex(char (*migetc)(void));
                </screen>
                </para>
                </sect2>

                <sect2 id="getint" xreflabel="getint">
                <title>getint</title>
                <para>
                Lee 4 caracteres ASCII que representan un n&uacute;mero en hexadecimal y los transforma un  n&uacute;mero entero de 16 bit.
                </para>
                <para>
                Por ejemplo, si tienes los caracteres '0','4','0' y '6', getint devuelve el n&uacute;mero 1030.
                </para>
                <para>
                <screen>
        miputc('0');
        miputc('4');
        miputc('0');
        miputc('6');    =>      0x0406  =>      1030    
                </screen>
                </para>
                <para>
                <screen>
        int getint(char (*migetc)(void));
                </screen>
                </para>
                </sect2>

                <sect2 id="getd" xreflabel="getd">
                <title>getd</title>
                <para>
                Lee un car&aacute;cter ASCII y lo transforma en una sola cifra decimal.
                </para>
                <para>
                Por ejemplo si lees el caracter "2" , "getd" lo transforma en el numero 2 en decimal codificado en binario BCD.
                </para>
                <screen>
        Transforma el caracter '0' en el n&uacute;mero 0.
        Transforma el caracter '1' en el n&uacute;mero 1.
        Transforma el caracter '2' en el n&uacute;mero 2.
        ...
        Transforma el caracter '9' en el n&uacute;mero 9.

        //cualquier otro numero se convierte 0xff
                </screen>
                <para>Para obtener el caracter se utiliza la funci&oacute;n migetc.</para>
                <screen>
        char geth(char (*migetc)(void));
                </screen>
                </sect2>

                <sect2 id="ejemplouart2" xreflabel="Ejemplo UART2">
                <title>Ejemplo de UART2</title>
                <para> para compilar necesitas los siguientes comandos </para>
                <para>
                <screen>
Ejemplo de compilaci&oacute;n : ./compila.sh ej_uart2 16f877a
                </screen>
                </para>
                <para> ej_uart2.c </para>

                <screen>
#include &lt;pic/p16f877a.h>

#define FOSC_HZ 20000000

#include &lt;uart.h>
#include &lt;uart2.h>

int main (void)
{
        char a=0x4a;
        int  x=1030;

        delayms(100);
        uart_open(SET_9600_8N1);
        uart_puts("UART2\n");

        puthex(uart_putc,a);
        uart_putc('\n');
        putint(uart_putc,x);
        uart_putc('\n');

        uart_puts("FIN\n");

        delayms(100);//dar un poco de tiempo para que se envie el ultimo caracter
        uart_close();

        return 0;       
}

                </screen>
                </sect2>                
                
        </sect1>

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-03-02 21:07:01, 0.5 KB) [[attachment:GenerarDoc.sh]]
  • [get | view] (2009-03-02 21:49:40, 642.0 KB) [[attachment:GtkPicGccAbout.eps]]
  • [get | view] (2009-03-02 21:50:10, 28.2 KB) [[attachment:GtkPicGccAbout.png]]
  • [get | view] (2009-03-02 21:47:10, 4.9 KB) [[attachment:adc.eps]]
  • [get | view] (2009-03-02 21:47:24, 0.9 KB) [[attachment:adc.png]]
  • [get | view] (2009-03-02 21:00:02, 0.1 KB) [[attachment:capitulo1.sgml]]
  • [get | view] (2009-03-02 21:00:35, 1.7 KB) [[attachment:capitulo1a.sgml]]
  • [get | view] (2009-03-02 21:00:50, 1.7 KB) [[attachment:capitulo1b.sgml]]
  • [get | view] (2009-03-02 21:01:15, 2.8 KB) [[attachment:capitulo1c.sgml]]
  • [get | view] (2009-03-02 21:01:25, 7.0 KB) [[attachment:capitulo1d.sgml]]
  • [get | view] (2009-03-02 21:01:33, 5.0 KB) [[attachment:capitulo1e.sgml]]
  • [get | view] (2009-03-02 21:01:41, 4.9 KB) [[attachment:capitulo1f.sgml]]
  • [get | view] (2009-03-02 21:02:02, 5.7 KB) [[attachment:capitulo1g.sgml]]
  • [get | view] (2009-03-02 21:02:26, 12.8 KB) [[attachment:capitulo1h.sgml]]
  • [get | view] (2009-03-02 21:02:37, 4.4 KB) [[attachment:capitulo1i.sgml]]
  • [get | view] (2009-03-02 21:02:46, 6.3 KB) [[attachment:capitulo1j.sgml]]
  • [get | view] (2009-03-02 21:02:54, 4.3 KB) [[attachment:capitulo1k.sgml]]
  • [get | view] (2009-03-02 21:03:01, 1.6 KB) [[attachment:capitulo1l.sgml]]
  • [get | view] (2009-03-02 21:03:14, 0.2 KB) [[attachment:capitulo2.sgml]]
  • [get | view] (2009-03-02 21:03:32, 2.6 KB) [[attachment:capitulo2a.sgml]]
  • [get | view] (2009-03-02 21:03:44, 2.8 KB) [[attachment:capitulo2b.sgml]]
  • [get | view] (2009-03-02 21:04:00, 22.0 KB) [[attachment:capitulo2c.sgml]]
  • [get | view] (2009-03-02 21:04:22, 0.3 KB) [[attachment:capitulo3.sgml]]
  • [get | view] (2009-03-02 21:04:59, 0.9 KB) [[attachment:capitulo3a.sgml]]
  • [get | view] (2009-03-02 21:05:11, 0.2 KB) [[attachment:capitulo4.sgml]]
  • [get | view] (2009-03-02 21:05:21, 1.4 KB) [[attachment:capitulo4a.sgml]]
  • [get | view] (2009-03-02 21:05:33, 2.7 KB) [[attachment:capitulo4b.sgml]]
  • [get | view] (2009-03-02 21:05:51, 5.6 KB) [[attachment:capitulo4c.sgml]]
  • [get | view] (2009-03-02 21:06:00, 0.2 KB) [[attachment:capitulo5.sgml]]
  • [get | view] (2009-03-02 21:06:20, 9.1 KB) [[attachment:capitulo5a.sgml]]
  • [get | view] (2009-03-02 21:49:04, 5.6 KB) [[attachment:compare.eps]]
  • [get | view] (2009-03-02 21:46:31, 1.1 KB) [[attachment:compare.png]]
  • [get | view] (2009-03-02 21:49:17, 7.6 KB) [[attachment:eeprom.eps]]
  • [get | view] (2009-03-02 21:48:01, 1.2 KB) [[attachment:eeprom.png]]
  • [get | view] (2009-03-02 21:06:33, 0.8 KB) [[attachment:ejemplos.sgml]]
  • [get | view] (2009-03-02 21:06:48, 1.7 KB) [[attachment:faq.sgml]]
  • [get | view] (2009-03-02 21:48:51, 6.3 KB) [[attachment:flash.eps]]
  • [get | view] (2009-03-02 21:50:20, 1.0 KB) [[attachment:flash.png]]
  • [get | view] (2009-03-02 21:50:40, 5.0 KB) [[attachment:i2c.eps]]
  • [get | view] (2009-03-02 21:50:50, 0.9 KB) [[attachment:i2c.png]]
  • [get | view] (2009-03-02 21:50:59, 8.8 KB) [[attachment:interrupt.eps]]
  • [get | view] (2009-03-02 21:51:09, 1.2 KB) [[attachment:interrupt.png]]
  • [get | view] (2009-03-02 21:07:16, 0.6 KB) [[attachment:introduccion.sgml]]
  • [get | view] (2009-03-02 21:07:33, 1.8 KB) [[attachment:introducciona.sgml]]
  • [get | view] (2009-03-02 21:07:43, 1.1 KB) [[attachment:introduccionb.sgml]]
  • [get | view] (2009-03-02 21:08:06, 1.6 KB) [[attachment:introduccionc.sgml]]
  • [get | view] (2009-03-02 21:08:17, 27.5 KB) [[attachment:introducciond.sgml]]
  • [get | view] (2009-03-02 21:08:29, 1.0 KB) [[attachment:introduccione.sgml]]
  • [get | view] (2009-03-02 21:08:42, 64.9 KB) [[attachment:introduccionf.sgml]]
  • [get | view] (2009-03-02 21:51:21, 6.1 KB) [[attachment:pinio.eps]]
  • [get | view] (2009-03-02 21:51:39, 1.0 KB) [[attachment:pinio.png]]
  • [get | view] (2009-03-02 21:51:54, 4.8 KB) [[attachment:pwm.eps]]
  • [get | view] (2009-03-02 21:52:03, 0.9 KB) [[attachment:pwm.png]]
  • [get | view] (2009-03-02 21:09:06, 1.1 KB) [[attachment:referencias.sgml]]
  • [get | view] (2009-03-02 22:26:32, 4.8 KB) [[attachment:spi.eps]]
  • [get | view] (2009-03-02 22:26:54, 0.8 KB) [[attachment:spi.png]]
  • [get | view] (2009-03-02 22:27:21, 7.6 KB) [[attachment:system.eps]]
  • [get | view] (2009-03-02 22:27:31, 1.2 KB) [[attachment:system.png]]
  • [get | view] (2009-03-02 22:27:42, 7.3 KB) [[attachment:timer0.eps]]
  • [get | view] (2009-03-02 22:28:00, 1.1 KB) [[attachment:timer0.png]]
  • [get | view] (2009-03-02 22:28:32, 7.1 KB) [[attachment:timer1.eps]]
  • [get | view] (2009-03-02 22:28:12, 1.0 KB) [[attachment:timer1.png]]
  • [get | view] (2009-03-02 22:28:45, 7.4 KB) [[attachment:timer2.eps]]
  • [get | view] (2009-03-02 22:28:55, 1.1 KB) [[attachment:timer2.png]]
  • [get | view] (2009-03-02 22:26:07, 587.2 KB) [[attachment:tutorial.pdf]]
  • [get | view] (2009-03-02 22:25:35, 2215.3 KB) [[attachment:tutorial.ps]]
  • [get | view] (2009-03-02 21:09:56, 4.4 KB) [[attachment:tutorial.sgml]]
  • [get | view] (2009-03-02 22:29:05, 5.3 KB) [[attachment:uart.eps]]
  • [get | view] (2009-03-02 22:29:16, 0.9 KB) [[attachment:uart.png]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

Heberge par Ikoula