|
|
- //模擬霍爾脈沖
- #include<reg51.h>
- sbit cp=P3^2; //將cp位定義為P3.2引腳,從此腳輸出脈沖信號(hào)
- /*****************************************************
- 函數(shù)功能:延時(shí)約600微秒
- ***************************************************/
- void delay()
- {
- unsigned char i;
- for(i=0;i<200;i++)
- ;
- }
- /*****************************************************
- 函數(shù)功能:主函數(shù)
- ***************************************************/
- void main(void)
- {
- while(1)
- {
- cp=1; //置高電平
- delay(); //等待600微秒
- cp=0; //置低電平
- delay(); //等待600微秒
- }
- }
復(fù)制代碼 |
|