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.

CC2652R7: Trying to write to SSI address space (0x40000000) causes hard fault.

Part Number: CC2652R7

I am trying to write a SPI driver for custom platform based on FreeRTOS and using the TI driverlib.

The following fails with a HardFault exception:

Fullscreen
1
2
3
4
PRCMPowerDomainOn(PRCM_DOMAIN_SERIAL | PRCM_DOMAIN_PERIPH | PRCM_DOMAIN_RFCORE | PRCM_DOMAIN_VIMS | PRCM_DOMAIN_CPU);
PRCMPeripheralRunEnable(PRCM_PERIPH_SSI0);
SSIConfigSetExpClkx(0x40000000, SysCtrlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, baudRate, 8);
SSIEnable(0x40000000);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Trying to access the SSI registers from base address 0x40000000 is causing hard fault. Have I failed to initialize something?

  • Hi Mike,

    Have you stepped through your code or used print logs to determine exactly which of these code lines causes the hard fault?  You could still reference the resources inside of C:\ti\simplelink_cc13xx_cc26xx_sdk_7_10_01_24\source\ti\drivers\spi\SPICC26X2DMA.c to better understand the intended setup and usage.  This includes flushing Fifos as well as disabling SSI operations and module interrupts within initHw. 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * ======== initHw ========
    */
    static void initHw(SPI_Handle handle)
    {
    ClockP_FreqHz freq;
    SPICC26X2DMA_Object *object = handle->object;
    SPICC26X2DMA_HWAttrs const *hwAttrs = handle->hwAttrs;
    flushFifos(hwAttrs);
    /* Disable SSI operation */
    SSIDisable(hwAttrs->baseAddr);
    /* Disable SPI module interrupts */
    SSIIntDisable(hwAttrs->baseAddr, SSI_RXOR | SSI_RXFF | SSI_RXTO | SSI_TXFF);
    SSIIntClear(hwAttrs->baseAddr, SSI_RXOR | SSI_RXTO);
    /* Set the SPI configuration */
    ClockP_getCpuFreq(&freq);
    SSIConfigSetExpClk(hwAttrs->baseAddr, freq.lo, object->format, object->mode, object->bitRate, object->dataSize);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    You could also add simplelink_cc13xx_cc26xx_sdk_7_10_01_24\source\ti\devices\cc13x2x7_cc26x2x7\driverlib\ssi.c (for example) directly to your project to build this resource with your project and further debug SSIConfigSetExpClk, among other functions.

    Regards,
    Ryan

  • Hi Ryan,

    Thank you for your response. Yes I've stepped through my code, even at the disassembly level. I've tried rearranging calls, etc. It always fails on the first access to the registers relative to the base address of 0x40000000. For example, SSIDisable(SSI0_BASE) will fail here:

    HWREG(ui32Base + SSI_O_CR1) &= ~(SSI_CR1_SSE);

    Where "ui32Base + SSI_O_CR1" is 0x40000004. It generates a HardFault exception as if 0x40000004 is an invalid address.

  • Are you having issues establishing any other peripherals (ADC, Timers, UART, etc)?  Make sure the Power, Clock, and GPIO dependencies are properly initialized beforehand (referring to their TI Driver -> Driverlib initialization instances accordingly).  It's possible to step through the spicontroller FreeRTOS example to further understand the recommended process.

    Regards,
    Ryan

  • Thanks for pointing me to this example! Hopefully it will help me understand what I'm missing.

  • This code was my answer:

    Fullscreen
    1
    2
    PRCMPowerDomainOn(PRCM_DOMAIN_SERIAL | PRCM_DOMAIN_PERIPH);
    while (PRCMPowerDomainsAllOn(PRCM_DOMAIN_SERIAL | PRCM_DOMAIN_PERIPH) != PRCM_DOMAIN_POWER_ON) {}
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX