標(biāo)題: FDC2214程序STM32 OLED串口源碼模板 [打印本頁]

作者: guzhen44    時間: 2018-7-20 18:18
標(biāo)題: FDC2214程序STM32 OLED串口源碼模板
FDC2214單片機源程序如下:
  1. #include "sys.h"
  2. #include "delay.h"
  3. #include "usart.h"
  4. #include "timer.h"
  5. #include "led.h"
  6. #include "oled.h"
  7. #include "fdc2214.h"
  8. #include "McuDataSend.h"

  9. float res0,res1,res2,res3;
  10. float temp0,temp1,temp2,temp3;  //初始值

  11. void Sys_Init(void)
  12. {
  13.         delay_init();                     //延時函數(shù)初始化          
  14.         NVIC_Configuration();//設(shè)置NVIC中斷分組2:2;2位搶占優(yōu)先級,2位響應(yīng)優(yōu)先級
  15.         //uart_init(115200);         //串口初始化為115200
  16.         LED_Init();
  17.         OLED_Init();
  18.         while(FDC2214_Init());
  19.         led=0;
  20.         delay_ms(100);
  21.         temp0 = Cap_Calculate(0);//讀取初始值
  22.         temp1 = Cap_Calculate(1);
  23.         temp2 = Cap_Calculate(2);
  24.         temp3 = Cap_Calculate(3);
  25.         TIM5_Ctrl_Init(2000-1,720-1);
  26. }

  27. int main(void)
  28. {
  29.   Sys_Init();
  30.         while(1)
  31.         {
  32.                 Oled_Printf_Float(0,1,res0-temp0,0);
  33.                 Oled_Printf_Float(0,3,res1-temp1,0);
  34.                 Oled_Printf_Float(0,5,res2-temp2,0);
  35.                 Oled_Printf_Float(0,7,res3-temp3,0);
  36.                 //printf("CH0;%3.3f CH1;%3.3f CH2;%3.3f CH3;%3.3f\r\n",res0-temp0,res1-temp1,res2-temp2,res3-temp3);
  37.                 while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);
  38.     //delay_ms(20);
  39.         }
  40. }


  41. //定時器5中斷服務(wù)程序
  42. void TIM5_IRQHandler(void)   //TIM5中斷
  43. {
  44.                 if(TIM5->SR&0X0001)//20ms定時中斷
  45.                  {
  46.                         res0 = Cap_Calculate(0);//采集數(shù)據(jù)
  47.                         res1 = Cap_Calculate(1);
  48.                         res2 = Cap_Calculate(2);
  49.                         res3 = Cap_Calculate(3);
  50.                   //        Data_Send_Status(res,0,0);
  51.                   //        printf("%5d : %5d : %5d\r\n",res0,res1,res2);
  52.                          led=~led;
  53.                  }
  54.          TIM5->SR&=~(1<<0);  //中斷標(biāo)志位清0,等待下一次中斷
  55. }
復(fù)制代碼

所有資料51hei提供下載:
FDC2214程序STM32OLED串口.rar (362.77 KB, 下載次數(shù): 24)







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