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.

RTOS/CC3220SF-LAUNCHXL: SPI_transfer causes runtime error for larger write transactions

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

I posted my error in old resolved thread, but it seems that resolved issues are not well looked at that much, so therefore I create a new one:

I am porting a STM32 application (without RTOS) to a CC3220 with TI-RTOS.

The code first does some SPI write operations to setup a transceiver correctly. After setup, I want to send a TX frame with SPI to the transceiver, but with SPI_transfer() I get an runtime error.
The TX frame is a bit larger than the previously done setup SPI writes (max 9 bytes for setup, the one that is fails 17 for TX frame)
I get the following data from the ROV:

HWI Exception:

Decoded exception
Decoded
Exception context
$addr
N/A
$type
ti.sysbios.family.arm.m3.Hwi.ExcContext
threadType
Hwi
threadHandle
0x20005510
threadStack
0x2000d508
threadStackSize
0x800
r0
0x1009ee1
r1
0x0
r2
0xc
r3
0x0
r4
0x2000c9d0
r5
0x20005548
r6
0x0
r7
0x1
r8
0x1
r9
0x0
r10
0x20004304
r11
0x0
r12
0x0
sp
0x2000c950
lr
0x100a785
pc
0x100a784
psr
0x610000c0
ICSR
0x440f003
MMFSR
0x0
BFSR
0x4
UFSR
0x0
HFSR
0x40000000
DFSR
0x0
MMAR
0xe000edf8
BFAR
0xe000edf8
AFSR
Exception call stack
0 ti_sysbios_knl_Semaphore_post__E at Semaphore.c:377 :
PC=0x0100A784
1 Power_getConstraintMask at :0 :
PC=0x00000000
2 Power_shutdown at :0 :
PC=0x00000000
0x0
Hard Fault: FORCED: BUSFAULT: IMPRECISERR

BIOS Errors:

mod
tab
inst
field
message
ti.sysbios.family.arm.m3.Hwi
Module
N/A
exception
An exception has occurred!
ti.sysbios.knl.Semaphore
Basic
(0x20005548)
pendElems
Error: Problem scanning pend Queue: JavaException: java.lang.Exception: Target memory read failed at address: 0xc, length: 8 This read is at an INVALID address according to the application's section map. The application is likely either uninitialized or corrupt.
ti.sysbios.knl.Task
Detailed
(0x20006070)
blockedOn
Invalid task internal state: pend element address (0x0) is not within the task's stack

Hwi Detailed view:

address
halHwiHandle
label
type
intNum
priority
group
subPriority
fxn
arg
irp
status
coreId
0x20000600
Dispatched
15
224
7
0
ti_sysbios_family_arm_m3_Timer_periodicStub__I
0x20000618
0x100e9e0
Enabled
0
0x20005e70
Dispatched
63
224
7
0
dmaErrorFxn
0x0
0x0
Enabled
0
0x20005ee0
Dispatched
21
224
7
0
UARTCC32XX_hwiIntFxn
0x100f6f0
0x100b080
Enabled
0
0x20005fc8
Dispatched
17
224
7
0
GPIO_hwiIntFxn
0x1
0x100ab0c
Enabled
0
0x20005510
Dispatched
192
224
7
0
spiHwiFxn
0x100f6b8
0x100a6b6
Enabled, Active
0

In this case I only want to write something to the device (because the device does not sent anything back in this case), so no RX buffer is initialized.
I use a global SPI TX buffer (which should be more than enough: SPI_BUFFER_LENGTH = 4224 bytes) and global SPI Transaction variable. All values in the buffer are reset and then set by the header and body buffers that I pass in the function (code below):

int writetospi(uint16_t headerLength,
			   const	uint8_t *headerBuffer,
			   uint32_t bodyLength,
			   const	uint8_t *bodyBuffer)
{
    /* Initialize master SPI transaction structure, and concatenate header and body buffers */
    memset((uint8_t *) masterTxBuffer, 0, SPI_BUFFER_LENGTH);
    memcpy((uint8_t*) masterTxBuffer , (uint8_t*)headerBuffer, headerLength);
    memcpy((uint8_t*) &masterTxBuffer[headerLength] , (uint8_t*)bodyBuffer, bodyLength);
    transaction.count = (uint32_t) headerLength + bodyLength;
    transaction.txBuf = (void *) masterTxBuffer;

    /**< Put chip select line low */
    GPIO_write(CS_GPIO, GPIO_PIN_RESET);

    /* Perform SPI transfer of header */
    bool transferOK = SPI_transfer(spi, &transaction); /* Send header in polling mode */
    if (!transferOK) {
        Display_printf(displaySerialPC, 0, 0, "Unsuccessful SPI transfer");
    }

    /**< Put chip select line high */
    GPIO_write(CS_GPIO, GPIO_PIN_SET);

I simply don't understand what is going wrong. If I check the signal with oscilloscope then all 18 bytes are send correctly (I can decode them with scope correctly), and even the SPI_Transaction status says SPI_TRANSFER_COMPLETED.
What I do see on the scope, is that the the GPIO_write function is never executed and that the CS stays low. From the debugging session I can also confirm that the transferOK part is never reached.

Could you guys help me a bit how this could happen? According to the documentation the SPI_Transaction does not require an initialized RX buffer, but it does state a warning:

 *  @warning The use of NULL as a sentinel txBuf or rxBuf value to determine
 *  whether the SPI transaction includes a tx or rx component implies
 *  that it is not possible to perform a transmit or receive transfer
 *  directly from/to a buffer with a base address of 0x00000000. To support
 *  this rare use-case, the application will have to manually copy the
 *  contents of location 0x00000000 to/from a temporary buffer before/after
 *  the tx/rx SPI transaction.

I also checked with RX buffer, but problem does not seem to be solved. Am I missing something very obvious? ROV does not give me any more information either.

Thanks in advance!

MJ