Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

DAVE™ Forum Discussions

User19094
Level 1
Level 1
Hi,

TIME CRITICAL PLEASE HELP!

I am seeing the same issue with SPI Master receive on XMC4800. I am using DIRECT Mode for both transmit and receive, no FIFO enabled, word length set to 8.
I see the data on the logic analyzer and all the receive data is there, but my SPI_MASTER_Receive function reads the received data intermittently and at other times reads either 0x00 or 0xFF.
I have followed various other threads on the same topic and patched bits and pieces but of no use. I need for this to work consistently.
I call a routine called Futek_Init(), right after DAVE_Init, to set custom settings on the SPI and the function definition for Futek_Init() is in futek_driver.c
Currently I am using SPI_MASTER_Receive, but I would also like to make it work with SPI_MASTER_Transfer.
I have written a function Futek_Transfer in futek_driver.c which uses SPI_MASTER_Transfer, but I have not tested it since SPI_MASTER_Receive is not working consistently. Please suggest edits to SPI_MASTER_Transfer as well.

I am using DAVE 4.4.2 IDE

main.c

void FutekDRDYIRQHandler(void)
{
DBG_PRINTF("DRDY Falling edge received, current state: %d\n", futek_state);
if (futek_state == 4)
futek_state = 0;
futek_state++;
}

int main(void) {

dave_status = DAVE_Init(); /* Initialization of DAVE APPs */
Futek_Init(); //defined in futek_driver.c

INTERRUPT_Enable(&INTERRUPT_1);
uint8_t send_command = 0x00;
while (1U) {

// ESC main loop
//DIGITAL_IO_SetOutputHigh(&VP_MOSI);
switch (futek_state)
{
case 1:
//DBG_PRINTF("Edge has fallen, sending command\n");
//Send command using SPI Transmit
DBG_PRINTF("sending command: 0x%02X\n", send_command);
Futek_Send_Command(send_command);
send_command++;
if (send_command == 0x0D)
send_command = 0x00;
futek_state++;
break;

case 2:
//DBG_PRINTF("Command sent\n");
//Do nothing
break;

case 3:
//DBG_PRINTF("Edge has fallen reading data\n");
//Read data using SPI Receive
Futek_Read_Response();
futek_state = 0;
break;

default:
//DBG_PRINTF("Data Read\n");
break;
}
}


Thanks,
Saili
0 Likes
0 Replies