Hi. I'm using KSDK3.00 and a modified example project. I'm writing this in KDS (No processor expert). I'm using the demo board FRDM K64F. I'm trying to add SD card functionality. When running the bare metal the program runs and I can write to an SD card.The problem is that the debugger breaks at default ISR when running using FREE RTOS.
The stack point where the program breaks is here:
Source code :
int main(void)
{
hardware_init();
OSA_Init();
uint32_t i, status;
#ifdef MPU_INSTANCE_COUNT
// disable MPU
for(i = 0; i < MPU_INSTANCE_COUNT; i++)
{
MPU_HAL_Disable(g_mpuBase[i]);
}
#endif
configure_sdhc_pins(0);
CLOCK_SYS_EnableSdhcClock(0);
GPIO_DRV_Init(sdhcCdPin, NULL);
sdhc_card_t card = {0};
sdhc_host_t host = {0};
sdhc_user_config_t config = {0};
// initialize user sdhc configuration structure
config.transMode = kSdhcTransModeAdma2;
config.clock = SDMMC_CLK_100KHZ;
config.cdType = kSdhcCardDetectGpio;
// initialize the SDHC driver with the user configuration
if (SDHC_DRV_Init(BOARD_SDHC_INSTANCE, &host, &config) != kStatus_SDHC_NoError)
{
PRINTF("ERROR\r\n");
}
if (kStatus_SDHC_NoError != SDCARD_DRV_Init(&host, &card))
{
PRINTF("SDCARD_DRV_Init failed\r\n");
SDHC_DRV_Shutdown(card.hostInstance);
}
PRINTF("sdcard initialized\r\n");
}
//Later write to SD Card
}
Thanks in advance, Sam
BAE Systems
Hi Sam,
I'm running into the same problem using KSDK1.3.0, writing this in KDS with Processor Expert and using the same demo board (FRDM K64F). My stack trace looks exactly like yours. It seems that you found the problem. Since I'm quite new to all of this, I couldn't figure out how to solve the problem - would you mind to share more details about your solution or give me some hints?
Many thanks!
Kai
Hi Sam,
from the stack trace, it looks to me that your code tries to use a semaphore with OSA_SemaWait(), but that semaphore has not been allocated/created yet. I suspect it is NULL, and therefore it causes a hard fault.
I suggest you debug down your stack trace down to OSA_SemaWait() and check why that semaphare (first parameter to OSA_SemaWait()) is not allocated. Maybe you missed to initialize something?
I hope this helps,
Erich
Thanks for the response. I checked the semaphore and it was not NULL.
I have found the problem. The initialisation works when run in a thread, the semaphore needs to be inside a thread to be able to pause it.
Cheers,
Sam