Send an SPI Sequence inside an interrupt in XMC4700

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

cross mob
Not applicable
Hello,

I would like to send an SPI sequence to an another board in different time Intervalls.
To do that I'm using Dave 4.3.2, the Timer APP and the Interrupt APP.
I connected the time event to the interrupt and changed the SPI receiving and transmitting settings to direct.

I tried different possibilities. The timer without the SPI works. As soon as I add the SPI TRansmit it doesn't anymore.

Is it possible to start an SPI Transmit in an Interrupt?
Here are the seetings and the code :

2432.attach
2433.attach

the code for the timer interrupt:



void Time_Interval_Event(void)
{
/* Acknowledge Period Match interrupt generated on TIMER_CCU_1 */
TIMER_ClearEvent(&TIMER_0);
/* When we Arrive at the end of the send values we repeat*/
if (index_count == NumValues){
index_count = 0;
}
/* if the new time starts, send the signal */
if (Timer_Tick_Count == 0){
SPI_MASTER_TransmitWord(&SPI_MASTER_0,IArr[index_count]);// send the wanted current Value

}

Timer_Tick_Count++;

/* when the current time step ends, reset the tick count, change the maximum tick count to the new value and move to the next current value */
if (Timer_Tick_Count == Max_Tick_Count ){
Timer_Tick_Count = 0;
index_count++;
Max_Tick_Count = idxMAXValues[index_count];
//new Max_Tick_Count value
}

/*disable CS to latch data */

TIMER_Start(&TIMER_0);

}





I thought about not putting the SPI in the timer event ans trigger the SPI transmit every time the timer finishes. It is also a possibility. I would like though to understand why it is not working in this setting. I tried placing break points to see what
happens. But it is not going through the values


thanks for the Help.
0 Likes
1 Reply
Not applicable
For those who will have the problem in the future:

As the SPI is interrupt based you can't use it in an Interrupt with the standard settings. Change the Mode to dierct and be careful how you build the function in the time event iunterrupt.
0 Likes