اطلاعیه

Collapse
No announcement yet.

SPI در CCS (دو)+ در خواست کمک

Collapse
این موضوع بسته شده است.
X
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    SPI در CCS (دو)+ در خواست کمک

    برای راه اندازی مد 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 چیه؟؟؟؟؟؟؟


    #2
    پاسخ : SPI در CCS (دو)+ در خواست کمک

    کامپایلر من CCS 4.033 هستش و این دستورات رو نداشت! ‎oo:‎ ولی خوب یه چیزایی حالیم شد. ببین دستور SETUP_SPI فقط برای کانفیگ کردن SPI به صورت سخت افزاری هست. یعنی فقط میکرو هایی که ماجول SPI رو دارن میتونی از اون دستور واسشون استفاده کنی. ولی دستور ‎#use_spi حالت توسعه یافته ی دستور SETUP_SPI هستش. توسط این دستور شما هم میتونید SPI سخت افزاری داشته باشی هم SPI نرم افزاری. خوب طبیعیه که باید پارامترهای بیشتری هم داشته باشه .
    به نظرم بیشترشون مشخصه که چیکار میکنن. هرکدوم که واسه شما مبهمه بگو تا یه کاریش کنیم . ‎:mrgreen:‎ . ‎
    ‏ پارامتر stream رو هم که پرسیدی بگم واسه اینه که شما میتونید چند تا دستور ‎#use_spi رو در یک برنامه داشته باشید . با عبارت stream میتونید واسه هرکدوم یه نام اختصاص بدید. بعد تو دستور SPI_XFER میتونید با تعیین کردن هر کدوم از stream ‎ ها دیتا رو توسط تنظیماب همون ‎#use_spi بفرستید یا دریافت کنید.‏

    دیدگاه

    لطفا صبر کنید...
    X