Other Parts Discussed in Thread: SYSBIOS,
Tool/software: TI-RTOS
Hey nice people :).
I am trying to connect to my SD card using the SPI driver.
and from the first time I try to send the first byte (0xFF) - the SPI_Transfer is stuck.
here is my code:
int main(void)
{
/* Call board init functions */
Board_initGeneral();
SPI_init();
/* Start kernel. */
/*UART_init();
UartLog_init(UART_open(Board_UART, NULL));
ICall_init();*/
Task_Handle myTsk;
Task_Params taskParams;
Error_Block eb2;
Error_init(&eb2);
/* Create 1 task with priority 15 */
Task_Params_init(&taskParams);
taskParams.stackSize = 512;
taskParams.priority = 2;
myTsk = Task_create(myTskFunc3, &taskParams, &eb2);
if (myTsk == NULL) {
System_abort("Task create failed");
}
BIOS_start();
return (0);
}
Void myTskFunc3(UArg arg0, UArg arg1)
{
System_printf("Start of Task \n");
System_flush();
ExtFlash_open();
}
/* See ExtFlash.h file for description */
bool ExtFlash_open(void)
{
bool f;
hFlashPin = PIN_open(&pinState, BoardFlashPinTable);
if (hFlashPin == NULL)
{
return false;
}
/* Make sure SPI is available */
f = Spi_open(SPI_BIT_RATE);
if (f)
{
rxSPI();
}
static inline UChar rxSPI()
{
SDSPIDataType rcvdat;
const uint8_t wbuf[] = { 0xFF };
int ret = Spi_write(wbuf, sizeof(wbuf));
}
static int Spi_write(const uint8_t *buf, size_t len)
{
SPI_Transaction masterTransaction;
masterTransaction.count = len;
masterTransaction.txBuf = (void*)buf;
masterTransaction.arg = NULL;
masterTransaction.rxBuf = NULL;
return SPI_transfer(spiHandle, &masterTransaction) ? 0 : -1;// HERE IS WHERE THE PROGRAM GETS STUCK
}
static bool Spi_open(uint32_t bitRate)
{
/* Configure SPI as master */
SPI_Params_init(&spiParams);
spiParams.bitRate = bitRate;
spiParams.mode = SPI_MASTER;
spiParams.transferMode = SPI_MODE_BLOCKING;
/* Attempt to open SPI. */
spiHandle = SPI_open(Board_SPI0, &spiParams);
return spiHandle != NULL;
}
When I debug and watch the RTOS - Scan for errors
I get all the time -
"Error: Problem scanning pend Queue: JavaException: java.lang.Exception: Target memory read failed at address: 0xbebebebe, length: 8This read is at an INVALID address according to the application's section map. The application is likely either uninitialized or corrupt."
I have several questiong -
1. The obvious.. why does this happen? I don't think it has to do with the sd card.. I think I misused a driver.. but I cant figure out which.
2. In order to initialize the SD CARD I need to set the MOSI and the CS high and send at least 74 clock pulses to the SCLK. does anyone know if I need to set the MOSI high with the GPIO driver?
and if so do I send the clock pulses with the SPI driver? Does that mean I use both drivers at the same time with the same pin? Is that OK?
3. Does the RTOS error has anything to do with the fact that the program gets stuck?
I would appreciate any help :).
Thank you,
Tomer.




