谁有MCS08DZ60的ADC程序,或者是demo程序也好,小弟学习学习!
- UID
- 803378
|
谁有MCS08DZ60的ADC程序,或者是demo程序也好,小弟学习学习!
看资料,编程序速度挺慢的,哪位大虾有现成的程序,小弟学习一下,感激不尽! |
|
|
|
|
|
- UID
- 169050
- 性别
- 男
|
/********************************************************
龙丘MC9S08DZ60多功能开发板V2.0
编写:龙丘
Designed by Chiu Sir
E-mail:chiusir@163.com
软件版本:V1.0
最后更新:2009年07月11日
相关信息参考下列地址:
博客: http://longqiu.21ic.org
淘宝店:http://shop36265907.taobao.com
*********************************************************/
#include "LQadc.h"
/**********************************************************************************************
* ADC_Init: This function initilizes the ADC module
*
* Parameters: none
*
* Subfunctions: none.
*
* Return: void
*********************************************************************************************/
void ADC_Init(void)
{
ADCCFG = 0x61; //busclk/2, Div by 8,ADCK = 1.5MHz
/* 0b0000000 0
* ||||||| |__ bit0,1: ADICLK : input clock select
* |||||||_|
* ||||||_____ bit2,3: MODE : Conversion Mode selection
* |||||_|
* ||||______ bit4: ADLSMP: long sample time configuration
* |||_______ bit5,6 : ADIV: Clock Divide Select
* ||______|
* |_________ bit7: ADLPC: Low power configuration
*/
ADCSC2 = 0x00; //
/* 0b00000000
* ||||||||__ bit0:
* |||||||___ bit1:
* ||||||____ bit2:
* |||||_____ bit3:
* ||||______ bit4: ACFGT: Compare function greater than enable
* |||_______ bit5: ACFE : Compare enable
* ||________ bit6: ADTRG: Conversion trigger select
* |_________ bit7: ADACT: Convert active
*/
//ADCCFG |= 0x04; //BIT2--3 00:8BIT,01:12BIT,10:102BIT,11:RES
/*Change the channel, to check the releation between pins and channels */
APCTL1 = 0x00; //disable all ADC ports0-19
APCTL2 = 0x00;
APCTL2 = 0xF0;
}
byte ADC_Cvt8B(unsigned char Channel)
{
if(Channel<24)
ADCSC1 =Channel;
else return 0;
while(!ADCSC1_COCO);
return ADCRL;
} |
飞思卡尔8/16/32位多功能开发板/下载器:
网站:http://www.lqist.cn,
淘宝店:http://shop36265907.taobao.com |
|
|
|
|
|
- UID
- 803449
|
可以用CodeWarrior的PE自动生成一个参考下,挺管用的。 |
|
|
|
|
|
- UID
- 803378
|
谢谢指点!小弟这就去试试啦 |
|
|
|
|
|