<li id="ar4ly"></li>

      <ol id="ar4ly"></ol>

    1. <button id="ar4ly"><object id="ar4ly"></object></button>
      <button id="ar4ly"></button>

      <progress id="ar4ly"><sub id="ar4ly"></sub></progress>

        1. 全國免費咨詢熱線:0512-57750678  18021615678
          您的位置:首頁 > 新聞資訊 > 單片機

          STM8S精確延時+LED閃爍

          分類:單片機 發布:2022-03-10 22:40:04 瀏覽:288次 Tag:
          1. #include"iostm8s105c4.h"  

          2. #define LED PC_ODR_ODR1  

          3. void GPIO_Init()  

          4. {  

          5.   PG_DDR_DDR0=1;  

          6.     

          7.   PG_CR1_C10=1;  

          8.     

          9.   PG_CR2_C20=0;  

          10.     

          11.   PG_ODR_ODR0=0;  

          12.     

          13.   PC_DDR_DDR1=1;  

          14.     

          15.   PC_CR1_C11=1;  

          16.     

          17.   PC_CR2_C21=0;  

          18.     

          19. }  

          20. /********** 微秒級延時程序*********/   

          21.   

          22. void Delayus(void)   

          23. {    

          24.   asm("nop");   

          25.     

          26.   asm("nop");   

          27.     

          28.   asm("nop");   

          29.    

          30.   asm("nop");    

          31. }  

          32. /********** 毫秒級延時程序**********/   

          33.   

          34. void Delayms(unsigned int time)   

          35.   

          36. {   

          37.       

          38.   unsigned int i;   

          39.       

          40.   while(time--)     

          41.       

          42.     for(i=900;i>0;i--)   

          43.       

          44.       Delayus();    

          45.     

          46. }   

          47.   

          48. main()  

          49. {  

          50.   GPIO_Init();  

          51.     

          52.   while(1)  

          53.   {  

          54.     LED=~LED;  

          55.       

          56.     Delayms(125);  

          57.   }  

          58. }  


          相關文章

          江蘇豹發力電子科技有限公司 版權所有 未經授權禁止復制或鏡像
          CopyRight 2022   www.nclinghe.com  All rights reserved

          電話:0512-57750678   E-mai:1989186555@qq.com  蘇ICP備2022026117號-1

          小的学生VIDEOSEX