標題: stm32f4xx多通道ADC代碼例程 [打印本頁]

作者: wangpan04321    時間: 2019-5-14 14:20
標題: stm32f4xx多通道ADC代碼例程
/*
* --------------------
* Company             :
* --------------------
* Project Name        : iCore3 adc
* Description         : iCore3 adc
* --------------------
* Tool Versions       : uVision V5.17.0.0
* Target Device       : STM32F407IGT6
* --------------------
* Engineer            : ysloveivy.
* Revision            : 0.01
* --------------------
* Engineer            :
* Revision            :
* Modified Date       :
* --------------------
* Additional Comments :
*
* --------------------
*/
//--------------------------- Include ---------------------------//
#include "..\include\led.h"
#include "..\include\main.h"
#include "..\include\usart.h"
#include "..\include\adc.h"
#include "..\fwlib\inc\stm32f4xx_gpio.h"

//---------------------------- Define ---------------------------//

//-------------------------- Variable ---------------------------//

//--------------------- Function Prototype ----------------------//

//--------------------------- Function --------------------------//
/*
* Name                : main
* Description         : ---
* Author              : ysloveivy.
*
* History
* --------------------
* Rev                 : 0.00
* Date                : 11/21/2015
*
* create.
* --------------------
*/
int main(void)
{
        int i;
        
        //初始化
        led.initialize();
        LED_RED_ON;
        usart4.initialize(115200);
        adc.initialize();
        
        usart4.printf("\x0c");                                   //清屏
               
        usart4.printf("\033[1;32;40m");                          //設置終端字體為綠色

        usart4.printf("\r\n\r\nhello! I am iCore3!\r\n\r\n\r\n");
        while(1){
                for(i = 0;i < 10000000;i++);
               
                //ADC 監(jiān)控電源
                for(i = 0;i < 5;i++){
                        adc.read(i);
                }
                //打印系統(tǒng)供電電壓,
                usart4.printf(" [V] %4.2fV, ",adc.value[0] * 6);
                usart4.printf("[I] %3.0fmA , ",adc.value[1] / 2* 1000.);
                usart4.printf("[1.2V] %4.2fV, ",adc.value[2]);
                usart4.printf("[3.3V] %4.2fV, ",adc.value[3] * 2);
                usart4.printf("[2.5V] %4.2fV\r",adc.value[4] * 2);               
        }
}


9_adc.7z

287.44 KB, 下載次數(shù): 47, 下載積分: 黑幣 -5

工程源碼






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1