標(biāo)題: 單片機(jī)修改底層函數(shù)putchar()實(shí)現(xiàn)printf()在LCD上輸出 程序Proteus仿真 [打印本頁(yè)]

作者: king123456.    時(shí)間: 2020-11-27 19:25
標(biāo)題: 單片機(jī)修改底層函數(shù)putchar()實(shí)現(xiàn)printf()在LCD上輸出 程序Proteus仿真
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機(jī)源程序如下:
  1. #include <reg51.h>
  2. #include <intrins.h>
  3. #include <stdio.h>
  4. #include <LCD.h>

  5. /*********************** 主函數(shù)函數(shù) *************************/
  6. void main(void){
  7.         LcdInitiate();
  8.         WriteAddress(0x00);
  9.         printf("Hello Everybody\n");
  10.         printf("Pai= %.4f",3.1415);
  11.         while(1);
  12. }

  13. /*********************** 修改底層輸出函數(shù) *************************/
  14. char putchar (char c){
  15.         if (c == '\n'){
  16.                 WriteAddress(0x40);  //        LCD光標(biāo)定位
  17.   }
  18.         else{
  19.                 WriteData(c);                 //        LCD輸出字符
  20.         }
  21.   return (c);
  22. }
復(fù)制代碼

所有資料51hei提供下載:
ex8-8.zip (67.75 KB, 下載次數(shù): 19)







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