This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: Coprocessor SPI communication

Part Number: CC2640R2F

hi team:

I am using the Sensor Controller Studio coprocessor for low-power design.

I want to write the corresponding configuration to the register address specified by the sensor using SPI communication,

such as writing 0x03 configuration information to the register at address 0x01 and writing 0x05 configuration information to the register at address 0x02.

I would like to know how this is achieved (can it be achieved through spiTx8bit (# cfg, txValue))?

Additionally, I noticed in your document that the SPI data transmission function only specifies the transmission method and data to be transmitted.

If I use  the API multiple times, does it default to writing configuration information from the register at address 0x01?

  • Hi Alex,

    You should use the example provided in the SPI Data Transfer section of the Sensor Controller Studio CC13x0 CC26x0 Help Documentation. 

    // MACRO: Writes an 8-bit value to an accelerometer register with 8-bit address
    macro spiWriteAccelReg(addr, value) {
        spiBegin(SPI_POL0_PHA0, AUXIO_SPI_CSN_ACCEL);
        spiTx8bit(SPI_POL0_PHA0, ACCEL_SPI_WRITE);
        spiTx8bit(SPI_POL0_PHA0, addr);
        spiTx8bit(SPI_POL0_PHA0, value);
        spiEnd(SPI_POL0_PHA0, AUXIO_SPI_CSN_ACCEL);
    }
    
    // Perform soft reset of the accelerometer, and wait for 50 ms
    spiWriteAccelReg(ACCEL_REG_SOFT_RESET, ACCEL_SR_KEY);
    fwDelayUs(50000, FW_DELAY_RANGE_50_MS);
    
    // Perform one-time configuration of the accelerometer
    spiWriteAccelReg(ACCEL_REG_INTMAP1, ACCEL_IM_DATA_READY);
    spiWriteAccelReg(ACCEL_REG_POWER_CTL, ACCEL_PC_LOW_NOISE_0 | ACCEL_PC_MEASURE_ON);

    Thus you would use spiBegin with the correct Chip Select pin for the device being queried (AUXIO_SPI_CSN_ACCEL in the example), followed by three consecutive spiTx8bit commands for write (ACCEL_SPI_WRITE in the example, or 0x00), register address (addr, 0x01 or 0x02 for your use case), and value (what the register should be written as).  Any following spiTx8bit commands would write values to the next register address and so on.  Then you would call spiEnd before repeating the process for the second device or selecting a new command.  A similar setup would be used to read register addresses.

    Regards,
    Ryan