ppg.c

来自「基于MB95F168气体检漏仪软件代码」· C语言 代码 · 共 126 行

C
126
字号

/**    THIS SAMPLE CODE IS PROVIDED AS IS. FUJITSU MICROELECTRONICS     **/
/** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR OMMISSIONS **/
/*****************************************************************************
 *  Date   :        2004/9/9
 *  PROJECT:        MB95110
 *  [16-bit PPG 1ch mode]
 *****************************************************************************/

#include "mb95100.h"
//#include "extern.h"
unsigned int PPGF=800,PPGD=2;
/*****************************************************************************/
/* 16bitPPG0 */
/*****************************************************************************/
void init_16bitPPG0(void)
{
/*****************************************************************************
	IO_PCNTL0.byte              PCNTL0
 *****************************************************************************/
	PCNTL0_OSEL = 0;	/* PPG output normal */
	PCNTL0_POEN = 1; /* PPG port is changed to PPG output from general port */
	PCNTL0_IRS0 = 1;
	PCNTL0_IRS1 = 0; /* PPG interrupt factor is set by counter underflow */
	PCNTL0_IRQF = 0;
	PCNTL0_IREN = 1; /* PPG interrupt enable */
	PCNTL0_EGS0 = 0;
	PCNTL0_EGS1 = 0;

/*****************************************************************************
	IO_PCNTH0.byte              PCNTH0
 *****************************************************************************/
	PCNTH0_PGMS = 0;
	PCNTH0_CKS0 = 0;
	PCNTH0_CKS1 = 0;
	PCNTH0_CKS2 = 0; /* clock = MCLK/1 */
	PCNTH0_RTRG = 0;
	PCNTH0_MDSE = 0;	/* PPG MODE */
	PCNTH0_STGR = 0;
	PCNTH0_CNTE = 0; /* PPG timer start */

/*****************************************************************************
	IO_PCSR0.word              IO_PCSR0
	IO_PDUT0.word              IO_PDUT0
 *****************************************************************************/
	PCSR0 = PPGF;
	PDUT0 = PPGF;
}


/*****************************************************************************/
/* 16bitPPG1 */
/*****************************************************************************/
void init_16bitPPG1(void)
{
/*****************************************************************************
	IO_PCNTL1.byte              PCNTL1
 *****************************************************************************/
	PCNTL1_OSEL = 0; /* PPG output normal */
	PCNTL1_POEN = 1; /* PPG port is changed to PPG output from general port */
	PCNTL1_IRS0 = 1;
	PCNTL1_IRS1 = 0; /* PPG interrupt factor is set by counter underflow */
	PCNTL1_IRQF = 0;
	PCNTL1_IREN = 1; /* PPG interrupt enable */
	PCNTL1_EGS0 = 0;
	PCNTL1_EGS1 = 0;

/*****************************************************************************
	IO_PCNTH1.byte              PCNTH1
 *****************************************************************************/
	PCNTH1_PGMS = 0;
	PCNTH1_CKS0 = 0;
	PCNTH1_CKS1 = 0;
	PCNTH1_CKS2 = 0; /* clock = MCLK/2 */
	PCNTH1_RTRG = 0;
	PCNTH1_MDSE = 0; /* PPG MODE */
	PCNTH1_STGR = 0;
	PCNTH1_CNTE = 0; /* PPG timer start */

/*****************************************************************************
	IO_PCSR1.word              IO_PCSR1
	IO_PDUT1.word              IO_PDUT1
 *****************************************************************************/
	PCSR1 = PPGF;
	PDUT1 = PPGD;
}


/*****************************************************************************/
/* 16bitPPG2 */
/*****************************************************************************/
void init_16bitPPG2(void)
{
/*****************************************************************************
	IO_PCNTL_2.byte              PCNTL_2
 *****************************************************************************/
	PCNTL2_OSEL = 0; /* PPG output normal */
	PCNTL2_POEN = 1; /* PPG port is changed to PPG output from general port */
	PCNTL2_IRS0 = 1;
	PCNTL2_IRS1 = 0; /* PPG interrupt factor is set by counter underflow */
	PCNTL2_IRQF = 0;
	PCNTL2_IREN = 1;/* PPG interrupt enable */
	PCNTL2_EGS0 = 0;
	PCNTL2_EGS1 = 0;

/*****************************************************************************
	IO_PCNTH2.byte              PCNTH2
 *****************************************************************************/
	PCNTH2_PGMS = 0;
	PCNTH2_CKS0 = 0;
	PCNTH2_CKS1 = 1;
	PCNTH2_CKS2 = 0; /* clock = MCLK/4 */
	PCNTH2_RTRG = 0;
	PCNTH2_MDSE = 0; /* PPG MODE */
	PCNTH2_STGR = 0;
	PCNTH2_CNTE = 0; /* PPG timer start */

/*****************************************************************************
	IO_PCSR2.word              IO_PCSR2
	IO_PDUT2.word              IO_PDUT2
 *****************************************************************************/
	PCSR2= PPGF;
	PDUT2= PPGD;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?