標(biāo)題: 51單片機(jī)模擬霍爾脈沖 [打印本頁]

作者: xueren    時(shí)間: 2013-7-19 02:26
標(biāo)題: 51單片機(jī)模擬霍爾脈沖
  1. //模擬霍爾脈沖
  2. #include<reg51.h>
  3. sbit cp=P3^2;    //將cp位定義為P3.2引腳,從此腳輸出脈沖信號(hào)
  4. /*****************************************************
  5. 函數(shù)功能:延時(shí)約600微秒
  6. ***************************************************/
  7. void delay()
  8. {
  9.    unsigned char i;      
  10.          for(i=0;i<200;i++)
  11.                ;   
  12. }
  13. /*****************************************************
  14. 函數(shù)功能:主函數(shù)
  15. ***************************************************/
  16. void main(void)
  17. {
  18.            while(1)
  19.             {
  20.               cp=1;     //置高電平
  21.               delay();  //等待600微秒
  22.               cp=0;     //置低電平
  23.               delay();   //等待600微秒
  24.            }
  25. }
復(fù)制代碼





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