I have a general approach where the Data in SDRAM is Transferred SPIC.DATA. I have added delay function in order to adjust my digital signal with the Sampling frequency.
/* Transfer data from internal memory via SPI from Master to Slave */
if ( (SWITCHPORTL.IN & PIN2_bm) == 0 )
{
flip = false;
j = 0;
while (j < NUM_BYTES)
{
if (flip == false)
{
// Set slave select line low (active) for Port C
PORTC.OUTCLR = PIN4_bm;
}
// Give the data to the data register of the Master
SPIC.DATA = __far_mem_read(j+SDRAM_ADDR);
if (flip == true)
{
// wait for the 2nd 8-bit-block to be send
-> delay 0.7us
_delay_us(0.7);
// Set slave select line high (inactive)
PORTC.OUTSET = PIN4_bm;
// delay to adjust to sampling frequency
100 kHz -> 6.9us; 200kHz -> 1.9us
_delay_us(1.9); }
flip = !flip;
j++;
}
}
How can i call two Slave select for this such that the data in SDRAM should be transferred to these two slaves alternatively one after the other?Lets consider the Data stored in SDRAM as A1A2A3A4A5 etc. so A1 A3 A5 ... is one set of data which should be transferred to my odd slave select and A2 A4 A6... is even set of data to other slave.
As Lundin says, you need to decide how to connect the slaves to your controller. The 128A1 has a few options.
I suggest option 1 or 2. Once you have connected the slaves, the programming will be very similar to what you already have.