I am trying to integrate the SDRAW example in the simple peripheral and running into some problems. I can initialize the sd card correctly. The card size etc is also recognized correctly meaning SPI communication is working okay. When writing a blob of data to the card (2048 bytes), I am running into a very specific problem. The system seems to freeze when writing the third sector. After setting a few breakpoints and navigating a maze of code, I am able to reduce the problem as summarized below.
The call trace before the freeze is as shown below
The SPICC26XXDMA_transfer function seems to be waiting for a semaphore as seen in the code below:
This particular line is executed at least 4 times before this without a problem. On the 5th time though, which corresponds with writing the 3rd data block, the system freezes. If I step through the assembly, I see that Semaphore.c is referenced. I also observed the memory region that is passed to the pend function and saw absolutely no changes there meaning the semaphore parameters hadn't changed.
What can cause this behavior? Is RTOS running out of memory? The sdraw and simple peripheral examples work alone without a hitch. I have used the sdraw example to write a few hundred MB of data and it always worked. Why am I witnessing this behavior after combining the two examples? Could someone suggest a solution for this?