برای راه اندازی مد SPI در CCS 2 نوع از دستورات را میتوان به کار برد :
SETUP_SPI(mode )
#use spi (options) + SPI_XFER( )
من به ترتیب سوالاتم رو می پرسم
سوالات مربوط به دستور اول رو در یک تاپیک جداگانه مطرح کردم تاپیک قبلی.
اول اینکه فرق دستور اول ودوم در چیه ؟؟؟؟؟؟؟؟؟ من فقط می دونم که دستور اول گزینه های کمتری داره ولی دستور دوم بیشتر!!!!!!!!!
در دستور دوم این گزینه ها مطرح هستند
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
اگر کسی میتونه یه کمک کنه در مورد هر کدوم از مد های بالا که میدونه چین وچه کار می کنن یه توضیحی بده؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟
توHelp CCS این توضیحات رو واسش داده که شاید کمک بیشتری بکنه؟؟
Purpose: The SPI library contains functions to implement an SPI bus. After setting all of the proper parameters in
#use spi, the spi_xfer() function can be used to both transfer and receive data on the SPI bus.
The SPI1 and SPI2 options will use the SPI hardware onboard the PIC. The most common pins present on
hardware SPI are: DI, DO, and CLK. These pins don’t need to be assigned values through the options; the
compiler will automatically assign hardware-specific values to these pins. Consult your PIC’s data sheet as
to where the pins for hardware SPI are. If hardware SPI is not used, then software SPI will be used.
Software SPI is much slower than hardware SPI, but software SPI can use any pins to transfer and receive
data other than just the pins tied to the PIC’s hardware SPI pins.
The MODE option is more or less a quick way to specify how the stream is going to sample data. MODE=0
sets IDLE=0 and SAMPLE_RISE. MODE=1 sets IDLE=0 and SAMPLE_FALL. MODE=2 sets IDLE=1 and
SAMPLE_FALL. MODE=3 sets IDLE=1 and SAMPLE_RISE. There are only these 4 MODEs.
SPI cannot use the same pins for DI and DO. If needed, specify two streams: one to send data and
another to receive data.
spi_xfer(stream, data, bits) دستور
در این دستور که زیر مجموعه دستور#use spi است معلوم نیست چه جوری مد انتقال رو فعال کنیم یا مد دریافت رو همچنین منظور از stream چیه؟؟؟؟؟؟؟
SETUP_SPI(mode )
#use spi (options) + SPI_XFER( )
من به ترتیب سوالاتم رو می پرسم
سوالات مربوط به دستور اول رو در یک تاپیک جداگانه مطرح کردم تاپیک قبلی.
اول اینکه فرق دستور اول ودوم در چیه ؟؟؟؟؟؟؟؟؟ من فقط می دونم که دستور اول گزینه های کمتری داره ولی دستور دوم بیشتر!!!!!!!!!
در دستور دوم این گزینه ها مطرح هستند
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
اگر کسی میتونه یه کمک کنه در مورد هر کدوم از مد های بالا که میدونه چین وچه کار می کنن یه توضیحی بده؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟
توHelp CCS این توضیحات رو واسش داده که شاید کمک بیشتری بکنه؟؟
Purpose: The SPI library contains functions to implement an SPI bus. After setting all of the proper parameters in
#use spi, the spi_xfer() function can be used to both transfer and receive data on the SPI bus.
The SPI1 and SPI2 options will use the SPI hardware onboard the PIC. The most common pins present on
hardware SPI are: DI, DO, and CLK. These pins don’t need to be assigned values through the options; the
compiler will automatically assign hardware-specific values to these pins. Consult your PIC’s data sheet as
to where the pins for hardware SPI are. If hardware SPI is not used, then software SPI will be used.
Software SPI is much slower than hardware SPI, but software SPI can use any pins to transfer and receive
data other than just the pins tied to the PIC’s hardware SPI pins.
The MODE option is more or less a quick way to specify how the stream is going to sample data. MODE=0
sets IDLE=0 and SAMPLE_RISE. MODE=1 sets IDLE=0 and SAMPLE_FALL. MODE=2 sets IDLE=1 and
SAMPLE_FALL. MODE=3 sets IDLE=1 and SAMPLE_RISE. There are only these 4 MODEs.
SPI cannot use the same pins for DI and DO. If needed, specify two streams: one to send data and
another to receive data.
spi_xfer(stream, data, bits) دستور
در این دستور که زیر مجموعه دستور#use spi است معلوم نیست چه جوری مد انتقال رو فعال کنیم یا مد دریافت رو همچنین منظور از stream چیه؟؟؟؟؟؟؟
دیدگاه