SPI Chip-Selects
Posted: Tue Sep 09, 2014 8:52 am
Using a NANO54415. I have multiple devices on the SPI port. The only place I've found to set the chip-selects is through the DSPIInit() function. Do I need to call DSPIInit() before every transfer when all I need to change is the chip-select, or can I just set Command_Mask accordingly before each transfer?
Update:
I'm using SPI1, and I'm running example program DSPI2Serial. I've tried running the example with each of the 3-chip-selects active. Chip-selects SPI_CS0 and SPI_CS1 work as expected, in that they are logic high when inactive and logic low when transferring. But SPI_CS2 does not work at all. It is always logic low, and never changes state.
I added the pin definitions for the chip-selects to the example, and then changed DSPIInit() for each chip-select, with CS = 0x0E for CS0, CS = 0x0D for CS1, and CS = 0x0B for CS2. Did I miss something?
Update 2:
I changed the 3 SPI chip selects to GPIO, and manually set and cleared each CS signal. Pins 15 and 37 work as expected. Pin 39 is stuck low. Is this pin even connected to anything on the NANO module, or is it mismarked, or what?
Pins[15].function(PIN_15_GPIO); // SPI Chip-Select 0
Pins[37].function(PIN_37_GPIO); // SPI Chip-Select 1
Pins[39].function(PIN_39_GPIO); // SPI Chip-Select 2
Pins[15] = 1;
Pins[37] = 1;
Pins[39] = 1;
DSPIInit(); // Keep overloaded defaults
while(1)
{
Pins[39] = 0;
DSPIStart(DEFAULT_DSPI_MODULE, TXBuffer,
RXBuffer, num, &DSPI_SEM); // Send data via DSPI
OSSemPend( &DSPI_SEM, 0 ); // Wait for DSPI to complete
//writeall(U1FD, (char*)RXBuffer, num); // Send DSPI RX via UART1
Pins[39] = 1;
OSTimeDly( 2 * TICKS_PER_SECOND );
}
Steve
Update:
I'm using SPI1, and I'm running example program DSPI2Serial. I've tried running the example with each of the 3-chip-selects active. Chip-selects SPI_CS0 and SPI_CS1 work as expected, in that they are logic high when inactive and logic low when transferring. But SPI_CS2 does not work at all. It is always logic low, and never changes state.
I added the pin definitions for the chip-selects to the example, and then changed DSPIInit() for each chip-select, with CS = 0x0E for CS0, CS = 0x0D for CS1, and CS = 0x0B for CS2. Did I miss something?
Update 2:
I changed the 3 SPI chip selects to GPIO, and manually set and cleared each CS signal. Pins 15 and 37 work as expected. Pin 39 is stuck low. Is this pin even connected to anything on the NANO module, or is it mismarked, or what?
Pins[15].function(PIN_15_GPIO); // SPI Chip-Select 0
Pins[37].function(PIN_37_GPIO); // SPI Chip-Select 1
Pins[39].function(PIN_39_GPIO); // SPI Chip-Select 2
Pins[15] = 1;
Pins[37] = 1;
Pins[39] = 1;
DSPIInit(); // Keep overloaded defaults
while(1)
{
Pins[39] = 0;
DSPIStart(DEFAULT_DSPI_MODULE, TXBuffer,
RXBuffer, num, &DSPI_SEM); // Send data via DSPI
OSSemPend( &DSPI_SEM, 0 ); // Wait for DSPI to complete
//writeall(U1FD, (char*)RXBuffer, num); // Send DSPI RX via UART1
Pins[39] = 1;
OSTimeDly( 2 * TICKS_PER_SECOND );
}
Steve