Elements:
port is A, B, C, D, E, F, G, H, J or ALL
Purpose:
This directive affects how the compiler will generate code for input and output instructions that follow. This directive takes effect until another #USE XXX_IO directive is encountered. The standard method of doing I/O will cause the compiler to generate code to make an I/O pin either input or output every time it is used. On the 5X processors this requires one byte of RAM for every port set to standard I/O.
Standard_io is the default I/O method for all ports.
When linking multiple compilation units be aware this directive only applies to the current compilation unit.
语法:#use fast_io(port)
port是A~G
目的:影响编译器如何产生输入输出代码,说明如下.这种指令有效,直到出现下一个#use xxxx_io为止.执行I/O的快速方法将使编译器不用对I/O方向寄存器进行编程就可执行I/O操作,但用户必须保证通过set_tris_X()来设置I/O方向寄存器.
例子:#use fast_io(A)例子文件:ex_cust.c;该文件在前面已经叙述过了
#USE FIXED_IO
语法:#use fixed_io(port_outputs=pin.pin?)
port是A~G.
pin是在device.h文件中定义的脚数之一.
目的: 影响编译器如何产生输入输出代码,说明如下. 这种指令有效,直到出现下一个#use xxxx_io为止. 执行设置I/O的方法将使编译器产生代码,这种代码使I/O在每次使用的时候,要么是输入,要么是输出.根据I/O方向寄存器中的信息对引脚进行编程(I/O方向寄存器实际上被执行但不操作),这将存储一个字节到标准I/O使用的RAM中.
例子:#use fixed_io(a_outputs=PIN_A2,PIN_A3) //将PINA2和PIN_A3设置为输出
Syntax:
#USE STANDARD_IO (port)
Elements:
port is A, B, C, D, E, F, G, H, J or ALL
Purpose:
This directive affects how the compiler will generate code for input and output instructions that follow. This directive takes effect until another #USE XXX_IO directive is encountered. The standard method of doing I/O will cause the compiler to generate code to make an I/O pin either input or output every time it is used. On the 5X processors this requires one byte of RAM for every port set to standard I/O.
Standard_io is the default I/O method for all ports.
When linking multiple compilation units be aware this directive only applies to the current compilation unit.
Examples:
#use standard_io(A
这些都是给编译器用的,你最好用每一种设置编译一次。
主程序只用一条语句,例如 output(PIN_B0,1)
再看看最终输出的语句。就知道区别了
#USE STANDARD_IO // 就先要强制给port方向定义,然后输出数据
#USE FAST_IO //直接输出数据到端口,简单说就会生成一句汇编
#USE FIXED_IO //相当于端口方向初始化啦吧。
搞明白了就回个贴
standard=======================================
.................... while(true){
.................... //output_bit( PIN_B0, 0);
.................... i=input(PIN_B0);
000F: BSF 06.0
0010: BCF 03.5
0011: CLRF 21
0012: BTFSC 06.0
0013: INCF 21,F
.................... }
0014: BSF 03.5
0015: GOTO 00F
fast================================
.................... while(true){
.................... //output_bit( PIN_B0, 0);
.................... i=input(PIN_B0);
000F: BCF 03.5
0010: CLRF 21
0011: BTFSC 06.0
0012: INCF 21,F
.................... }
我们习惯了自己定义方向,自己设置IO,它这么一来,反而让我的程序莫名奇妙了。我通常的做法,是
#USE FAST_IO
然后自己直接输出数据到端口,关键是自己要清楚啥IO的方向。
一周热门 更多>