• #pragma vector 皇星客栈


    在IAR编译器里用关键字来__interrupt来定义一个中断函数。用#pragma vector来提供中断函数的入口地址。


    #pragma vector = 0x12    //定时器0溢出中断入口地址
    __interrupt void time0(void)
    {
     ;
    }
        上面的入口地址写成#pragma vector=TIMER0_OVF_vect更直观,每种中断的入口地址在头文件里有描述。函数名称time0可以为任意名称。中断函数会自动保护局部变量,但不会保护全局变量。

    1 .内在函数也可以称为本征函数
            编译器自己编写的能够直接访问处理器底层特征的函数。在intrinsics.h中有描述完整类型在comp_a90.h里有进一步的简化书写方式

    延时函数,以周期为标准
            __delay_cycles(unsigned long );
            如果处理器频率为1M,延时100us,如下:
            __delay_cycles(100 );
            当然你也可以对该函数进行修改:
            #define CPU_F 1000000
            #define delay_us (unsigned long) __delay_cycles((unsigned long )*CPU_F)
            #define delay_ms (unsigned long) __delay_cycles((unsigned long )*CPU_F/1000)

    2.中断指令
       __disable_interrupt( );//插入CLI指令, 也可以用_CLI();也可以SREG_Bit7=0;
        __enable_interrupt( );// 插入SEI指令,也可以用_SEI();也可以SREG_Bit7=1;
        其实对于状态字的置位和清零只有BSET S 和BCLR S两条指令。像SEI不过是BSET 7;的另一个名字而已。AVR指令中还有很多类似的现象,如:ORI 和 SBR 指令完全一样,号称130多条指令的AVR其实没有那么多指令的。

    3.从FLASH空间指定地址读取数据
    __extended_load_program_memory(unsigned char __farflash *);
    __load_program_memory(unsigned char __flash *);


    4.乘法函数
    __fracdtional_multiply_signed(signed char, signed char);
    __fractional_multiply_signed_with_unsigned(signed char, unsigned char);
    __fractional_multiply_unsigned(unsigned char, unsigned char);
    //以上为定点小数乘法
    __multiply_signed(signed char, signed char);//有符号数乘法
    __multiply_signed_with_unsigned(signed char, unsigned char);
    //有符号数和无符号数乘法
    __multiply_unsigned(unsigned char, unsigned char);//无符号数乘法

     5.半字节交换指令
    __swap_nibbles(unsigned char);

    6.MCU控制指令
    __no_operation();//空操作指令
    _NOP();
    __sleep();//休眠指令
    _SLEEP();
    __watchdog_reset();//看门狗清零
    _WDR();

  • 相关阅读:
    MasterPage里使用TreeView保存状态功能
    JavaScript 如何将字符串转换为数值
    asp.net 样式GridView CSS的完整样式表
    CSS Frames LayoutsCSS框架
    Fix: .Net 2.0 or 3.5 Setup Project Requires .Net Framework version 4.0
    Design Pattern Resources
    Agile Method
    The Art of Debugging
    WPF Control Layout
    Getting Started With Setup Projects
  • 原文地址:https://www.cnblogs.com/huangxingkezhan/p/2953102.html
Copyright © 2020-2023  润新知