Attachment 'capitulo1i.sgml'

Download

        <sect1 id="timer0" xreflabel="timer0">
                <title>M&oacute;dulo TIMER0</title>
                <para>Autor: Santiago Gonzalez</para>
                <para>Correo: santigoro en gmail.com</para>
                <para>Aqu&iacute; se muestran las funciones para trabajar con el TIMER0 de los PIC16F.
                </para>

                <sect2 id="timer0init" xreflabel="timer0_init">
                <title>timer0_init</title>
                <para>Inicializa TIMER0 con reloj interno (modo timer) o externo (modo counter).</para>

                <screen>
        void timer0_init(unsigned char intern_extern);
                </screen>
                <para>
                intern_extern Establece si se usa reloj interno 
                o reloj/est&iacute;mulo externo (modo counter).
                </para>
                <screen>
        TIMER_INTERN    :Usa reloj interno.
        COUNTER_EXTERN  :Usa reloj/est&iacute;mulo externo (modo counter)

        timer0_init(TIMER_INTERN);
                </screen>
                <para>
                Pone a 0 la cuenta del timer0 y borra flag de interrupciones.
                El contador se incrementa en cada ciclo de intrucciones (Freq.Osc. / 4)
                si no se usa el prescaler.
                </para>
                </sect2>


                <sect2 id="timer0setedge" xreflabel="timer0_set_edge">
                <title>timer0_set_edge</title>
                <para>Establece si el incremento de contador se produce 
                en el flanco de subida o en el flanco de bajada (modo counter).</para>
                <screen>
        void timer0_set_edge(unsigned char set_risfal);
                </screen>
                <para>
                Pone a 0 la cuenta del timer0 y borra flag de interrupciones
                El contador se incrementa en cada subida o bajada en el pin RA4 
                si no se usa prescaler.
                </para>
                <para>
                set_risfal Establece si el incremento de contador se produce 
                en el flanco de subida o en el flanco de bajada.
                </para>
                <para>Las posibles opciones son: </para>
                <screen>
         RIS_EDGE  
         FAL_EDGE  
                </screen>
                <para>
                Donde RIS_EDGE establece incremento de contador en flanco de subida (rising) 
                y FAL_EDGE en flanco de bajada (falling).
                </para>
                <screen>
        timer0_set_edge(FAL_EDGE);
                </screen>

                </sect2>


                <sect2 id="timer0setprescaler" xreflabel="timer0_set_prescaler">
                <title>timer0_set_prescaler</title>
                <para>
                Asigna prescaler a timer0 (esto anula el uso de prescaler en watchdog)
                y establece el valor del prescaler.
                </para>
                <screen>
        void timer0_set_prescaler(unsigned char set_presc);
                </screen>
                <para>set_presc Establece el valor del prescaler.</para>
                <para>Las posibles opciones son: </para>
                <screen>
                        // Frecuencia de ciclo de instrucciones
        T0_PRESC_DIV_2  // (FOSC/4) del PIC dividido entre 2
        T0_PRESC_DIV_4  // (FOSC/4) del PIC dividido entre 4
        T0_PRESC_DIV_8  
        T0_PRESC_DIV_16 
        T0_PRESC_DIV_32 
        T0_PRESC_DIV_64 
        T0_PRESC_DIV_128        
        T0_PRESC_DIV_256        
        T0_PRESC_OFF    // asignado a wathdog
                </screen>
                <para>
                Cualquier operaci&oacute;n de escritura en el registro TMR0 automaticamente
                pone a 0 el contador del prescaler, aunque mantiene su configuraci&oacute;n.
                </para>
                </sect2>


                <sect2 id="timer0write" xreflabel="timer0_write">
                <title>timer0_write</title>
                <para>Establece (escribe a TMR0) el valor del contador TMR0.</para>
                <screen>
        void timer0_write(unsigned char set_count);
                </screen>
                <para>set_count Establece el valor del contador TMR0.</para>
                </sect2>


                <sect2 id="timer0read" xreflabel="timer0_read">
                <title>timer0_read</title>
                <para>Lee el valor del contador TMR0.</para>
                <screen>
        #define timer0_read()           TMR0
                </screen>
                </sect2>

                <sect2 id="ejemplotimer0" xreflabel="Ejemplo TIMER0">
                <title>Ejemplo M&oacute;dulo TIMER0</title>
                <para> para compilar necesitas los siguientes comandos </para>
                <para>
                <screen>
Ejemplo de compilacion : ./compila.sh ej_timer0.c 16f877a
                </screen>
                </para>
                <para> ej_timer0.c </para>
                <screen>
/*
Ejemplo de utilizaci&oacute;n de las funciones del m&oacute;dulo TIMER0.
v&aacute;lido para la familia 16f87Xa,
En este ejemplo se utiliza el timer0 como contador, 
conectar un pulsador entre RA4 y 0V 
y una resistencia pull-up de unos 5 Kohm entre RA4 y Vdd (+5v),
conectar un led u otra salida a RB7.
RB7 se pondr&aacute; en estado alto (Vdd) cuando se pulse 4 veces.
*/

#include &lt;pic/p16f877a.h>
#include &lt;timer0.h>

int main(void) 
{       
        TRISAbits.TRISA4 = 1;
        TRISBbits.TRISB7 = 0;
        PORTBbits.RB7 = 0;

        timer0_init(COUNTER_EXTERN);    // Inicia timer0 modo contador (reloj o 
                                        // est&iacute;mulo externo en RA4)

        timer0_set_edge(FAL_EDGE);      // Establece incremento de contador en flanco de bajada

        timer0_set_prescaler(PRESC_DIV_2);      // Establece prescaler en frecuencia 
                                                // de instrucciones / 2

        while (timer0_read() &lt; 2);   // Espera aqui mientras la cuenta del timer &lt; 2

        PORTBbits.RB7 = 1;
}

                </screen>
        </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