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.

CCS/CC2640R2F: BIM spi not working correctly on cc2640r2f to read image from flash

Part Number: CC2640R2F

Tool/software: Code Composer Studio

Hi all,

I did 2 projects with cc2640r2f using external flash (AT45DB041E adesto) to implement OAD.

in the first project the OAD working fantastic, and I can download an image save it to the external flash and check the CRC, and read it i the bootloader after the reset.

in the second project, I can download the image and check the CRC correctly, but after the reset the bootloader failed to read the image from the flash.

I tried to connect a scope to understand what is the problem then every thing gone OK. and the bootloader manage to read the image.

I disconnect scope the problem return again, then after some research I found that I need to connect a resistor between the MOSI and the ground in order to activate the SPI in the bootloader. 

the bootloader (BIM) is same in the two projects and the HW schematics are same. but only one project need the resistor between the MOSI and the ground, I can't know what is the difference!

in the application code with implement the OAD I can access the external flash and read the image from it without any resistor, but in the bootloader I do need the resistor.

the bootloader SPI driver is "bsp_spi.c" , attached code sample.

SSIIntDisable(BLS_SPI_BASE, SSI_RXOR | SSI_RXFF | SSI_RXTO | SSI_TXFF);
SSIIntClear(BLS_SPI_BASE, SSI_RXOR | SSI_RXTO);
SSIConfigSetExpClk(BLS_SPI_BASE,
BLS_CPU_FREQ, /* CPU rate */
SSI_FRF_MOTO_MODE_0, /* frame format */
SSI_MODE_MASTER, /* mode */
bitRate, /* bit rate */
8); /* data size */
IOCPinTypeSsiMaster(BLS_SPI_BASE, BSP_SPI_MISO, BSP_SPI_MOSI,
IOID_UNUSED /* csn */, clkPin);
SSIEnable(BLS_SPI_BASE);

and the application SPI driver is "SPICC26XXDMA.c", attached sample code

SPI_Params spiParams;
SPI_Params_init(&spiParams);
spiParams.bitRate = defaultParams.spiBitRate;
spiParams.frameFormat = defaultParams.spiFrameFormat;

/* Try open the SPI */
spiHandle = SPI_open(flashHwAttrs->spiIndex, &spiParams);

Does any one have some advices?

Best regards,

Amir

  • Hi Amir,

    I don't see any reason why you would have to mount a pull-down resistor on the MOSI line for the SPI to work.
    The fact that it is enough to connect a scope to the line for me sounds like it most likely is a hardware problem.

    Have you checked all solder joints and connections and made sure everything is ok?

    Regarding the difference between the TI-RTOS SPI driver and the bsp_spi.c implementation it could be related to how they initialize the MOSI pin. The TI-RTOS SPI driver will initialize it as a output driver low, I don't think the bsp_spi.c one does this as it simply configure the pin as an output without setting the value to any specific direction.

    You could try to add this to the bsp_spi.c before SSI enable and see if it makes a difference in your case:

    GPIO_clearDio(BSP_SPI_MOSI);
  • Correction: The problem is in the MISO line and not MOSI as I mentioned above

  • Hi Amir,

    In case of MISO the SPI driver will configure the MISO pin with a pull-down while the bsp_spi.c version will not. This should explain the difference you are seeing. You could try to add the following in the bsp_spi.c file before SSI enable:

    IOCIOPortPullSet(BSP_SPI_MISO, IOC_IOPULL_DOWN);