打印

MSP430 C语言的关键字扩展

[复制链接]
140|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
mmbs|  楼主 | 2023-3-27 08:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

1.interrupt 用于中断函数。
定义如下:
语法: interrupt void 函数名()  
       或者
       interrupt[中断向量]void 函数名()
参数:中断函数没有参数。中断函数需要指定中断向量。
返回:中断函数一般是void,没有返回。
说明:interrupt关键字声明了在处理器发生中断时调用;函数的参数必须为空

2.monitor 使函数进入原型(atomic)操作状态。
定义如下:
语法:monitor 函数类型 函数名(参数表)
参数:该函数可以有参数,也可以没有参数。
返回:函数可以有返回,也可以没有返回。
说明:monitor关键字使得在函数执行期间禁止中断,使函数执行不可中断;在其它所有方面,有monitor声明的函数则与普通函数相同。

3.no_init
语法:no_init 变量声明
说明:在默认情况下,MSP430的C语言编译器将变量存放在主RAM中,并在启动时对其进行初始化。no_init类型修正符使编译器把变量放在非易失RAM区中(如EEPROM、FLASH等),在启动时也不对它们进行初始化。在no_init变量的声明中,不能含有初始化。如果用了非易失RAM,连接时要安排在非易失RAM区,地址范围为0x0000~0xFFFF。实际可用范围是0x200~0xFFDF.

4.sfrb  用于声明单字节I/O数据类型对象。
语法:sfrb 标识符=常量表达式
说明:sfrb表示一个I/O寄存器,具有以下特点:等价于无符号字符,只能直接寻址,它驻留地址范围0x00~0xFF之内,例如:sfrb PxOUT =0x0021;  定义了Px端口的输出寄存器

5.sfrw  用于声明双字节I/O数据类型对象。
语法:sfrw 标识符=常量表达式
说明:sfrw表示一个I/O寄存器,具有以下特点: 等价于无符号字符,它只能直接寻址,它驻留地址范围0x100~0x1FF之内,例如:sfrw WDTCTL =0x0021; //定义了看门狗的寄存器。




Intrinsic functions summary

To use intrinsic functions in an application, include the header file intrinsics.h.

Note that the intrinsic function names start with double underscores, for example:

__disable_interrupt

The following table summarizes the intrinsic functions:

Intrinsic function
Description
__bcd_add _ type
Performs a binary coded decimal operation
__bic_SR_register
Clears bits in the SR register
__bic_SR_register_on_exit
Clears bits in the SR register when an interrupt or monitor function returns
__bis_SR_register
Sets bits in the SR register
__bis_SR_register_on_exit
Sets bits in the SR register when an interrupt or monitor function returns
__data16_read_addr
Reads data to a 20-bit SFR register
__data16_write_addr
Writes data to a 20-bit SFR register
__data20_read_ type
Reads data which has a 20-bit address
__data20_write_ type
Writes data which has a 20-bit address
__delay_cycles
Provides cycle accurate code size minimized delay functionality
__disable_interrupt
Disables interrupts
__enable_interrupt
Enables interrupts
__even_in_range
Makes switch statements rely on the specified value being even and within the specified range
__get_interrupt_state
Returns the interrupt state
__get_R4_register
Returns the value of the R4 register
__get_R5_register
Returns the value of the R5 register
__get_SP_register
Returns the value of the stack pointer
__get_SR_register
Returns the value of the SR register
__get_SR_register_on_exit
Returns the value that the processor status register will have when the current interrupt or monitor function returns
__low_power_mode_ n
Enters a MSP430 low power mode
__low_power_mode_off_on_exit
Turns off low power mode when a monitor or interrupt function returns
__no_operation
Inserts a NOP instruction
__op_code
Inserts a constant into the instruction stream
__set_interrupt_state
Restores the interrupt state
__set_R4_register
Writes a specific value to the R4 register
__set_R5_register
Writes a specific value to the R5 register
__set_SP_register
Writes a specific value to the SP register
__swap_bytes
Executes the SWPB instruction



使用特权

评论回复
沙发
zwsam| | 2023-3-29 09:37 | 只看该作者

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

173

主题

6353

帖子

3

粉丝