復制代碼
- /***********************************************************
- -功能描述:開機初始化
- -參數說明:無
- -返回說明:無
- ***********************************************************/
- void Init_Start(void)
- {
- ADC_InitTypeDef ADC_InitStruct;
- /*ADC配置*/
- ADC_InitStruct.refSource = REF_INT; //內部基準源
- ADC_InitStruct.dataAlign = AD_LEFT; //ADC數據為左對齊
- ADC_InitStruct.channel = 7;
- ADC_InitStruct.prescaler = CK_PS32; //32預分頻
- ADC_InitStruct.adcEnabled=1; //使能ADC
- ADC_Init(&ADC_InitStruct);
#ifndef _AVR_ADC_H
#define _AVR_ADC_H
#include "my_define.h"
#define ADC_PRECL(x) st(ADCSR &= 0xf8;ADCSR |= (x);)
#define ADC_EN() st(ADCSR |= BV(ADEN);)
#define ADC_CLOSE() st(ADCSR &= ~BV(ADEN);)
#define ADC_START() st(ADCSR |= BV(ADSC);)
#define ADC_END() (ADCSR & BV(ADSC))
enum
{
REF_EXT = 0,
REF_VCC = 1,
REF_INT = 3,
AD_LEFT = 1,
AD_RIGHT = 0,
CONT_MOD = 1,
ONCE_MOD = 0,
CK_PS2 = 1,
CK_PS4,
CK_PS8,
CK_PS16,
CK_PS32,
CK_PS64,
CK_PS128,
};
typedef struct
{
uint8 channel : 4;
uint8 def : 1;
uint8 dataAlign : 1;
uint8 refSource : 2;
uint8 prescaler : 3;
uint8 adcIE : 1;
uint8 def1 : 1;
uint8 convertMod: 1;
uint8 start : 1;
uint8 adcEnabled: 1;
}ADC_InitTypeDef;
void ADC_Init(ADC_InitTypeDef *parameter);
#endif
秉燭良宵 發表于 2016-3-9 16:37
排序全部亂了,不知道是怎么回事
admin 發表于 2016-3-10 16:48
謝謝分享黑幣已經奉上,附件里面有完整的程序吧
秉燭良宵 發表于 2016-3-10 08:33
http://www.raoushi.com/bbs/dpj-45487-1.html
昨晚錄制了一個配置外部中斷、UASRT、ADC、定時器輸出PWM的 ...
秉燭良宵 發表于 2016-3-11 10:30
這幾天在考慮寫一個STM32的庫函數配置助手,也打算嘗試用excel實現,如果實在不行再換VB。有沒有感興趣的, ...
歡迎光臨 (http://www.raoushi.com/bbs/) | Powered by Discuz! X3.1 |