?? ad1utl.c
字號:
/*""FILE COMMENT""*************************************************************
* System Name : for eduction (NO TRANSFERRING)
* File Name : ad1utl.c
* Contents : A-D conversion
* Model : for OAKS8-LCD Board
* CPU : R8C/Tiny series
* Compiler : NC30WA(V.5.30 Release 1)
* OS : not be used
* Programer : RENESAS Semiconductor Training Center
* Note : for OAKS8-R5F21114FP(R8C/11 group,20MHz)
*******************************************************************************
* COPYRIGHT(C) 2004 RENESAS TECHNOLOGY CORPORATION
* AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED
*******************************************************************************
* History : ---
*""FILE COMMENT END""*********************************************************/
/*===== include file =====*/
#include "defs.h" /* common symbol definition */
#include "target.h" /* SFR section definition file */
#include "ad1utl.h" /* header file for A-D conversion control */
/*===== define function prototype =====*/
/*===== define variable =====*/
static int init_hard; /* hardware initialization management variable */
/* 0:not be initialized丄1:initialized */
/*""FUNC COMMENT""*************************************************************
* ID : ---
* function name : void AD1__initialize(void)
* function : initialization for A-D conversion
* parameter : none
* return : none
* function used : none
* notice :
* History :
*""FUNC COMMENT END""*********************************************************/
void AD1__initialize(void)
{
init_hard = TRUE; /* A-D conversion "initialized" */
adcon0 = 0x89; /* set AD control register 0 */
/* 10001001 */
/* |||||+++ select AN1 port */
/* ||||+--- loop mode */
/* |||+---- select port P0 group */
/* ||+----- reservation bit */
/* |+------ stop A-D conversion */
/* +------- fAD 2 frequency division */
adcon1 = 0x28; /* set A-D control register 1 */
/* 00101000 */
/* |||||+++ reservation bit */
/* ||||+--- 10 bits mode */
/* |||+---- enable CKS0 bit */
/* ||+----- connect Vref */
/* ++------ reservation bit */
adcon2 = 0x01; /* set A-D control register 2 */
/* 00000001 */
/* |||||||+ have sample & hold */
/* +++++++- reservation bit */
adst = 1; /* start A-D conversion */
}
/*""FUNC COMMENT""*************************************************************
* ID : ---
* function name : int AD1__getad1(void)
* function : get A-D conversion result
* parameter : none
* return : int ; A-D conversion result
* function used : none
* notice : ad register consists of 16 bits, if to get A-D conversion
* : result of 10 bits solution, must mask 6 bits from b15 to b10
* History :
*""FUNC COMMENT END""*********************************************************/
int AD1__getad1(void)
{
if(init_hard){ /* if initialized */
return ad; /* return result */
}
/* if not initialized */
return ERR; /* return error */
}
/* #############################################################################
* ### private function
*/
/******************************************************************************
end of file
******************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -