Hi guys,
I'm programming an hardware step sequencer and i need to use SPI.transfer in a timer interrupt and out too.
when timer interrupt appair the program stop and freeze.
I try to use SPI.usingInterupt() function but i don't know timer interrupt number.
Somebody ever use SPI in timer interrupt ?
Thank you for your help
I'm programming an hardware step sequencer and i need to use SPI.transfer in a timer interrupt and out too.
when timer interrupt appair the program stop and freeze.
I try to use SPI.usingInterupt() function but i don't know timer interrupt number.
Somebody ever use SPI in timer interrupt ?
Thank you for your help
Code:
ISR(TIMER1_COMPA_vect) { CountPPQN(); }
void CountPPQN()
{
if (ppqn++ >= 96) ppqn = 1;
if (isRunning){
if(ppqn%4 == 0){
TRIG_CS_LOW;
SPI.transfer(byte(value >> 8));
SPI.transfer(byte(value));
TRIG_CS_HIGH;
if(curStep++ == 16) curStep = 1;
}
}
}
Code:
////////////////////////Setup//////////////////////
void setup()
{
InitIO();
InitStepButtonCounter();
InitConfigButtonCounter();
TimerStart();
#if DEBUG
Serial.begin(9600);
#endif
sei();
}
////////////////////////Loop///////////////////////
void loop()
{
SW_CS_HIGH;
tempDin[0][1] = SPI.transfer(0);
tempDin[1][1] = SPI.transfer(0);
tempDin[2][1] = SPI.transfer(0);
tempDin[3][1] = SPI.transfer(0);
tempDin[4][1] = SPI.transfer(0);
SW_CS_LOW;
}