ISR (SPI_STC_vect) firing too many times - 8bit LabView boolean array along MOSI
in labview, i'm testing spi 8-bit signal loop, pretty identical to:
http://www.ni.com/example/9398/en/
the labview program acts master...the arduino mega slave
when use logic analyzer @ points right before signal reaches mega spi lines, looks fine , dandy (ss, sck, mosi produce correct results.)
however, more coding isr routine incorrectly handle capturing of byte.
if send number "11" labview (which gets converted lsb boolean array), isr (spi_stc_vect) in arduino program fires off couple hundred times.
i receive ton of serial prints byte (i verify analyzer 8 bits sent, yet printing 'b' doesn't verify that.) i want know how capture 1 byte labview, process correctly, , print it. i did not use reverse array in labview, @ best should getting larger results 256 (just confirm i'm not reversing lsb order.) but not occurring.
the byte should have bits containing number values ranging 1-20.
i new this, please go detail if have to.
i attached .txt show 'serial.println(b)' output (i apologize length.)
http://www.ni.com/example/9398/en/
the labview program acts master...the arduino mega slave
when use logic analyzer @ points right before signal reaches mega spi lines, looks fine , dandy (ss, sck, mosi produce correct results.)
however, more coding isr routine incorrectly handle capturing of byte.
if send number "11" labview (which gets converted lsb boolean array), isr (spi_stc_vect) in arduino program fires off couple hundred times.
code: [select]
volatile boolean process_it;
char buff[10];
volatile byte spot;
// here's code setup:
void setup() {
serial.begin(115200);
serial.println("begin transmissions, rotundra!");
pinmode(miso, output);
spcr |= bit(spe);
spcr |= bit(spie);
//spi.attachinterrupt();
}
// here's loop:
void loop() {
valuesspi();
delay(20);
}
// here's 'valuesspi()' , 'isr(spi_stc_vect)' functions:
void valuesspi() {
if (process_it) {
buff[spot] = 0;
spot = 0;
process_it = false;
}
isr (spi_stc_vect) {
byte b = spdr;
serial.println(b);
if (spot < 11) {buff[spot++] = b;}
else {process_it = true;}
}
i receive ton of serial prints byte (i verify analyzer 8 bits sent, yet printing 'b' doesn't verify that.) i want know how capture 1 byte labview, process correctly, , print it. i did not use reverse array in labview, @ best should getting larger results 256 (just confirm i'm not reversing lsb order.) but not occurring.
the byte should have bits containing number values ranging 1-20.
i new this, please go detail if have to.
i attached .txt show 'serial.println(b)' output (i apologize length.)
don't put serial.print()s isr. in loop() after isr has completed.
...r
...r
Arduino Forum > Using Arduino > Programming Questions > ISR (SPI_STC_vect) firing too many times - 8bit LabView boolean array along MOSI
arduino
Comments
Post a Comment