哪位大神能详细解释一下# USE SPI()的用法啊?
哪位大神能详细解释一下# 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 C的么?都不用这个语句吗? 我不是拿来党,我试了几十次了,网上也搜,但是CCS资料的太少了。谁给解释一下咋用这个啊?北京的可以请吃饭{:smile:} 这个用的人应该不是很多吧
看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
这两个范例可以研究、尝试下
大概能知道工作原理吧
还有好奇楼主用的什么版本了? yklstudent 发表于 2014-3-29 19:40
这个用的人应该不是很多吧
看CCS帮助手册应该多少也能懂点
#use spi(DI=PIN_B1, DO=PIN_B0, CLK=PIN_B2, EN ...
我用的5.010
你写的那个我试了,怎么都不行。我看了下汇编,它走的还是硬件通道
zhiguangqi 发表于 2014-3-30 20:28
我用的5.010
你写的那个我试了,怎么都不行。我看了下汇编,它走的还是硬件通道
...
看手册上提示 可以用内部硬件SPI模块 也可以是模拟SPI
关键看你怎么设置使用了
最上面显然是软件模拟SPI的
完全可以用的 用不起来还是你自己的问题 亲,这不是CCS的问题,是C的问题~
给个建议,如果是宏的问题,可以让编译器输出预编译文件,这里面宏都已经展开了,有时候可以帮助debug~ error_dan 发表于 2014-3-30 22:26
亲,这不是CCS的问题,是C的问题~
给个建议,如果是宏的问题,可以让编译器输出预编译文件,这里面宏都已经展开 ...
谢谢回电 yklstudent 发表于 2014-3-30 21:50
看手册上提示 可以用内部硬件SPI模块 也可以是模拟SPI
关键看你怎么设置使用了
最上面显然是软件模拟SPI ...
好的,谢谢了
页:
[1]