標(biāo)題:
STM8S-A05_ADC連續(xù)轉(zhuǎn)換代碼
[打印本頁(yè)]
作者:
1234Gary1234
時(shí)間:
2018-12-20 14:21
標(biāo)題:
STM8S-A05_ADC連續(xù)轉(zhuǎn)換代碼
STM8 adc驅(qū)動(dòng)
單片機(jī)源程序如下:
/**
********************************** STM8S ***********************************
* @文件名 : main.c
* @作者 : strongerHuang
* @庫(kù)版本 : V2.2.0
* @文件版本 : V1.0.0
* @日期 : 2017年04月10日
* @摘要 : 主函數(shù) - Demo軟件工程
******************************************************************************/
/*----------------------------------------------------------------------------
更新日志:
2017-04-10 V1.0.0:初始版本
----------------------------------------------------------------------------*/
/* 包含的頭文件 --------------------------------------------------------------*/
#include "bsp.h"
#include "bsp_adc.h"
#include "bsp_timer.h"
#include "bsp_uart.h"
/************************************************
函數(shù)名稱 : System_Initializes
功 能 : 系統(tǒng)初始化
參 數(shù) : 無(wú)
返 回 值 : 無(wú)
作 者 : strongerHuang
*************************************************/
void System_Initializes(void)
{
BSP_Initializes();
ADC_Initializes();
TIMER_Initializes();
UART_Initializes();
}
/************************************************
函數(shù)名稱 : main
功 能 : 主函數(shù)入口
參 數(shù) : 無(wú)
返 回 值 : 無(wú)
作 者 : strongerHuang
*************************************************/
void main(void)
{
uint32_t voltage; //電壓
uint8_t vol_buf[4]; //打印BUF
System_Initializes();
while(1)
{
LED_ON; //LED亮
TIMDelay_Nms(500);
LED_OFF; //LED滅
TIMDelay_Nms(500);
voltage = ADC_Read(); //讀取電壓
vol_buf[0] = (voltage/1000)%10 + '0'; //轉(zhuǎn)換為打印BUF
vol_buf[1] = (voltage/100)%10 + '0';
vol_buf[2] = (voltage/10)%10 + '0';
vol_buf[3] = (voltage)%10 + '0';
UART1_SendNByte(vol_buf, 4); //打印電壓(1000倍)
}
}
#ifdef USE_FULL_ASSERT //斷言(參考官方)
void assert_failed(u8* file, u32 line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/**** Copyright (C)2017 strongerHuang. All Rights Reserved **** END OF FILE ****/
復(fù)制代碼
所有資料51hei提供下載:
STM8S-A05_ADC連續(xù)轉(zhuǎn)換.zip
(212.23 KB, 下載次數(shù): 25)
2018-12-20 14:20 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1