標題: STM32F103+LCD1602+DSB18B20源程序 求幫助 [打印本頁]

作者: 張桐    時間: 2020-10-9 17:07
標題: STM32F103+LCD1602+DSB18B20源程序 求幫助
可以作為學習使用


單片機源程序如下:
  1. /*----------------------------------------------------------------------------
  2. * Name:    Blinky.c
  3. * Purpose: tested by hardware; but can not run on proteus platform
  4. * Version: V1.00
  5. *----------------------------------------------------------------------------*/



  6. #include "stm32f10x.h"
  7. #include "system.h"
  8. #include "LCD1602.h"
  9. #include "DS18B20.h"
  10. #include "stdio.h"

  11. unsigned char i;
  12. unsigned char a[16];
  13. struct temp tt;

  14. int main (void)
  15. {
  16.          RCC->APB2ENR|=(1<<2); //enable port A clock
  17.   GPIOA->CRL=0x33333333; //50Mhz, push-pull
  18.         GPIOA->CRH=0x00033003; //PA8,PA11,PA12 of LCD1602
  19.         
  20.   RCC->APB2ENR|=(1<<3);//DS18B20         
  21.                         
  22.     LCDInit();
  23.     LCDHideCursor();

  24.   while(1)
  25.   {
  26.       //delay_ms(1000);
  27.                  tt=Read_Temperature();
  28.              //Delay(0x0FFFEF);
  29.                  sprintf(&a[0],"%6.2f",(float)((tt.H<<8)+tt.L)/16);
  30.                 //        sprintf(&a[0],"%5d",i);
  31.                   //GPIO_SetBits(GPIOA,1<<i);
  32.                         SetCurPos(1,1);
  33.             LCDPrint(&a[0]);
  34.                         i++;
  35.    
  36.    }

  37. }
復制代碼

所有資料51hei提供下載:
4_LCD1602&amp;&amp;DS18B20.7z (283.56 KB, 下載次數(shù): 25)






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