-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I connect more than 3 SPI devices (IDFGH-1225) #3527
Comments
Hello.
CS of SPI device #1 is GPIO_XX You set GPIO_XX GPIO_YY GPIO_ZZ manualy. |
Hi all, Please take care of all cases where //Set CS pin, CS options
if (dev_config->spics_io_num >= 0) {
spicommon_cs_initialize(host, dev_config->spics_io_num, freecs, !(spihost[host]->flags&SPICOMMON_BUSFLAG_NATIVE_PINS));
} BTW, kindly notice: more slaves connected to the same SPI bus will cause the timing to be worse. The delay of all lines will be greater, which will limit your working frequency. |
@ginkgm Thank you for the explanation. I am currently trying to get the software CS working for more than 3 devices, will be dropping any new development update/question on this issue. Please feel free to close the issue. |
@ginkgm I tried this and my 4th SPI device still wouldn't respond. My setup looks something like this - void swcs_pre_cb (spi_transaction_t *trans){
// reset the pin
gpio_set_level(CS_PIN, 0);
return;
}
void swcs_post_cb (spi_transaction_t *trans) {
// set the pin
gpio_set_level(CS_PIN, 1);
return;
}
...
extern "C" void app_main(void)
{
...
spi_device_interface_config_t dev_config;
dev_config.command_bits = 0;
dev_config.address_bits = 8;
dev_config.dummy_bits = 0;
dev_config.mode = 0;
dev_config.duty_cycle_pos = 128; // default 128 = 50%/50% duty
dev_config.cs_ena_pretrans = 0; // 0 not used
dev_config.cs_ena_posttrans = 0; // 0 not used
dev_config.clock_speed_hz = 1000000;
dev_config.spics_io_num = -1; // SW cs
dev_config.flags = 0; // 0 not used
dev_config.queue_size = 1;
dev_config.pre_cb = swcs_pre_cb;
dev_config.post_cb = swcs_post_cb;
hspi.addDevice(&dev_config, &spi_handle);
gpio_set_direction(CS_PIN, GPIO_MODE_INPUT_OUTPUT);
PIN_FUNC_SELECT(CS_PIN, PIN_FUNC_GPIO);
...
} The exact same configuration works for the first 3 devices with
I could not determine which parts in P.S. For my 4th device, I am taking care that the CS pins don't get initialized within |
* Utilize prepoc symbols for SPI pins * Adjusts for GPIO pins when ALTERNATE_PINS is set
Closing this issue, if you are still countering this issue, please open a new ticket. |
spi_master.c
driver is implemented in such a way that there is a hard limit on the maximum number of SPI devices that can be communicated with (as shown here). I have two questions regarding this issue -P.S. - I tried to manually change the macro value to more than 3, but it didn't change anything (besides not giving the error). I found a reddit thread that discusses this issue and a possible workaround, but I didn't understand how to use the workaround in my code.
The text was updated successfully, but these errors were encountered: