芯势力 发表于 2025-2-12 16:47:17

Ai8051U创新风格库函数学习打卡

原贴链接https://www.stcaimcu.com/forum.p ... mp;extra=#pid138723
打卡第一集:第一集 I/O口模式和传统的外部中断
(1)编译图片:

(2)代码如下:

#include <AI8051U.H>
#include "set_int.h"
#include "set_io.h"
#include "intrins.h"

void Delay1us(void)      //@24.000MHz
{
      unsigned long edata i;

      _nop_();
      _nop_();
      _nop_();
      i = 4UL;
      while (i) i--;
}

voidmain(void)
{
      EAXFR = 1;
      CKCON = 0;
      WTST = 0;
      set_io_mode(pu_mode, Pin40, Pin00, Pin01, Pin02, Pin03,Pin_End);
      P40=0;
      set_io_mode(hz_mode, Pin32, Pin33,Pin34,Pin35, Pin_End);            
      set_io_mode(en_pur, Pin32,Pin33,Pin34,Pin35, Pin_End);
      Delay1ms( );
      set_int_mode(falling_edge_mode,Int0,Int1,Int_End);
      
      
      EA = 1;
      while(1)
      {
               
                if(get_int_state(INT0))
                {
               
                        P00 = ~P00;
                }
                if(get_int_state(INT1))
                {
               
                        P01 = ~P01;
                }
                P02 = P34;
                P03 = P35;
      }
}
页: [1]
查看完整版本: Ai8051U创新风格库函数学习打卡