哪位大神能详细解释一下# USE SPI()的用法啊?
Syntax:
#use spi (options)
Elements:
Options are separated by commas and may be:
MASTER
Set the device as the master.
SLAVE
Set the device as the slave.
BAUD=n
Target bits per second, default is as fast as possible.
CLOCK_HIGH=n
High time of clock in us (not needed of BAUD= is used).
CLOCK_LOW=n
Low time of clock in us (not needed of BAUD= is used).
DI=pin
Optional pin for incoming data.
DO=pin
Optional pin for outgoing data.
CLK=pin
Clock pin.
MODE=n
The mode to put the SPI bus.
ENABLE=pin
Optional pin to be active during data transfer.
LOAD=pin
Optional pin to be pulsed active after data is transferred.
DIAGNOSTIC=pin
Optional pin to the set high when data is sampled.
SAMPLE_RISE
Sample on rising edge.
SAMPLE_FALL
Sample on falling edge (default).
BITS=n
Max number of bits in a transfer.
SAMPLE_COUNT=n
Number of samples to take (uses majority vote).
LOAD_ACTIVE=n
Active state for LOAD pin (0, 1).
ENABLE_ACTIVE=n
Active state for ENABLE pin (0, 1).
IDLE=n
Inactive state for CLK pin (0, 1).
ENABLE_DELAY=n
Time in us to delay after ENABLE is activated.
LSB_FIRST
LSB is sent first.
MSB_FIRST
MSB is sent first.
STREAM=id
Specify a stream name for this protocol.
SPI1
Use the hardware pins for SPI Port 1
SPI2
Use the hardware pins for SPI Port 2
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
看CCS帮助手册应该多少也能懂点
#use spi(DI=PIN_B1, DO=PIN_B0, CLK=PIN_B2, ENABLE=PIN_B4, BITS=16)
// uses software SPI
#use spi(FORCE_HW, BITS=16, stream=SPI_STREAM)
// uses hardware SPI and gives this stream the name SPI_STREAM
这两个范例可以研究、尝试下
大概能知道工作原理吧
还有好奇楼主用的什么版本了?
我用的5.010
你写的那个我试了,怎么都不行。我看了下汇编,它走的还是硬件通道
给个建议,如果是宏的问题,可以让编译器输出预编译文件,这里面宏都已经展开了,有时候可以帮助debug~
一周热门 更多>