Microchip Technology dsPIC33F Family Manual de usuario Pagina 20

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 26
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 19
dsPIC33F/PIC24H Family Reference Manual
DS70205C-page 11-20 © 2010 Microchip Technology Inc.
11.7.3 Synchronous Counter Mode
The 32-bit timer operates similarly to a 16-bit timer in Synchronous Counter mode. Example 11-8
illustrates the code sequence to set up Timer2 and Timer3 in 32-bit Synchronous Counter mode.
Example 11-8: Initialization Code for 32-Bit Synchronous Counter Mode
T3CONbits.TON = 0; // Stop any 16-bit Timer3 operation
T2CONbits.TON = 0; // Stop any 16/32-bit Timer3 operation
T2CONbits.T32 = 1; // Enable 32-bit Timer mode
T2CONbits.TCS = 1; // Select External clock
T2CONbits.TCKPS = 0b00; // Select 1:1 Prescaler
TMR3 = 0x00; // Clear 32-bit Timer (msw)
TMR2 = 0x00; // Clear 32-bit Timer (lsw)
PR3 = 0x0002; // Load 32-bit period value (msw)
PR2 = 0x0000; // Load 32-bit period value (lsw)
IPC2bits.T3IP = 0x01; // Set Timer3 Interrupt Priority Level
IFS2bits.T3IF = 0; // Clear Timer3 Interrupt Flag
IEC0bits.T3IE = 1; // Enable Timer3 interrupt
T2CONbits.TON = 1; // Start 32-bit Timer
/* Example code for Timer3 ISR */
void __attribute__((__interrupt__, no_auto_psv)) _T3Interrupt(void)
{
/* Interrupt Service Routine code goes here */
IFS0bits.T3IF = 0; // Clear Timer3 Interrupt Flag
}
Vista de pagina 19
1 2 ... 15 16 17 18 19 20 21 22 23 24 25 26

Comentarios a estos manuales

Sin comentarios