芯征程 发表于 2025-2-12 16:46:31

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

第一集:I/O口模式设置
传统外部中断P3.2,P3.3,P3.4,P3.5
控制P0口的LED亮灭
(1)编译图片:

2.程序:

#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--;
}

void main(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);
      Delay1us();
      set_int_mode(falling_edge_mode,Int0,Int1,Int_End);
      set_int_mode(rising_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;
      }
}
3.学习视频






芯征程 发表于 2025-2-14 13:37:41

第二集:所有普通 I/O口 都支持的外部中断
1.图片

2.程序

#include <AI8051U.H>
#include "io_int.h"
#include "set_io.h"
#include "set_uart.h"

void main(void)
{
        EAXFR = 1;
        CKCON = 0;
        WTST = 0;
        set_io_mode(hz_mode,Pin32,Pin33,Pin36,Pin_End);
        set_io_mode(en_pur,Pin32,Pin33,Pin36,Pin_End);
        set_io_mode(pp_mode,Pin37,Pin_End);
       
        set_ioint_mode(falling_edge_mode,Pin32,Pin_End);
       set_ioint_mode(rising_edge_mode,Pin33,Pin_End);

        set_ioint_mode(en_int,Pin32,Pin33,Pin_End);
       
        set_uart_mode(Uart1,"115200bps",Use_Timer2,Base_8b,"64byte",Uart1_P36_7,Uart_End);
       
        EA = 1;
        while(1)
        {
               
                if(get_ioint_state(Pin32))//设置P32为下降沿中断
                {
                        uart_printf(Uart1,"P32 Click\r\n");
                }
                if(get_ioint_state(Pin33))//设置P33为上升沿中断
                {
                        uart_printf(Uart1,"P33 Click\r\n");
                }
        }
}
3.学习视频:



页: [1]
查看完整版本: Ai8051U创新风格库函数学习打卡