Graynomad:
That wasn't a stand-alone program, what happened to all your setup() code (most or which you don't need anyway I think).
Rob
Hi..!!
With this code , attached result is coming.
#include "pins_arduino.h"
#include <SPI.h>
#define size_data 4 // is there 4 bytes? if not change this and the arrays.
byte send_04_data[size_data] = {1,2,3,7}; // you fill in the numbers
byte send_06_data[size_data] = {3,8,7,9};
byte * data_ptr;
int byte_count = 0;
void setup (void)
{
// have to send on master in, *slave out*
pinMode(MISO, OUTPUT);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode (SPI_MODE2);
SPI.setClockDivider(SPI_CLOCK_DIV64) ;
// turn on SPI in slave mode
SPCR |= _BV(SPE);
// turn on interrupts
SPCR |= _BV(SPIE);
// disable timer interrupts
TIMSK0 = 0;
// interrupt for SS falling edge
//attachInterrupt (0, ss_falling, FALLING);
// disable timer interrupts
TIMSK0 = 0;
}
ISR (SPI_STC_vect) {
byte c = SPDR;
if (byte_count == 0)
{
data_ptr = (c == 0x04) ? send_04_data : send_06_data;
SPDR = *(data_ptr + byte_count);
byte_count++; }
else
{
SPDR = 0; //******** Added
}
if (byte_count = size_data)
byte_count = 0;
}
void loop (void)
{
} // end of loop
TEK0014.BMP (76.1 KB)
TEK0011.BMP (76.1 KB)