Renesas Single-Chip Microcomputer M38C89T-ADF Manual de usuario Pagina 128

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 138
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 127
5-12
Rev.1.00 May 22 2012
REJ09B0566
5
4BUsage Examples
5.6 26BCompare Match Timer
5.6. Compare Match
T
i
m
e
r
Figure 5-7 shows an example of Compare Match Timer usage. One channel is used to generate interrupts at regular intervals.
/* PDL functions */
#include "r_pdl_cpg_library_SH7267.h"
#include "r_pdl_pfc_library_SH7267.h"
#include "r_pdl_io_port_library_SH7267.h"
#include "r_pdl_cmt_library_SH7267.h"
/* PDL device-specific definitions */
#include "r_pdl_definitions.h"
void CMT_handler(void);
void CMT_Test(void)
{
uint8_t Flags;
uint16_t Counter;
/* Modify the MCU clocks */
R_CPG_Set(18E6, 144E6, 36E6, PDL_CPG_CK_2, PDL_CPG_OUT_CK_01);
/* Setup the LED1 */
R_PFC_Modify(PDL_PJCR1, PDL_PFC_AND, 0xF0FF);
R_IO_PORT_Set(PDL_IO_PORT_J_6, PDL_IO_PORT_OUTPUT, 0);
/* turn off the LED */
_check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_HIGH);
/* Create a CMT timer with 1 us second period */
R_CMT_Create(0,PDL_CMT_PERIOD,1,PDL_NA,2);
/* turn on the LED */
_check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_LOW);
R_CMT_Create(0, PDL_CMT_FREQUENCY, 100, CMT_handler, 7);
R_CMT_Control(0, PDL_CMT_START, 10E3);
/* turn on the LED */
_check_Wr_Pin_H(PDL_IO_PORT_J_6,PDL_IO_PORT_LOW);
R_CMT_Create(0, PDL_CMT_FREQUENCY, 200, CMT_handler, 7);
R_CMT_Control(0, PDL_CMT_START, 0x55AA);
R_CMT_Read(2, &Flags, &Counter);
R_CMT_Destroy(0);
while(1);
}
void CMT_handler(void)
Vista de pagina 127
1 2 ... 123 124 125 126 127 128 129 130 131 132 133 ... 137 138

Comentarios a estos manuales

Sin comentarios