I communicate with another processor using SPI.
When I call pi_bus_add_device() I note that CS goes low for 5uS or so. CS goes low even if I add a device on another SPI host e.g. adding a device to VSPI causes a glicth on HSPI.
These glitches upsets the remote slave as the slave and our life tests. We have written test software looking for bus issues when temperature, emi, etc testing - CS without data is a fault.
How do I stop CS glitching?
v4.0-dev-562-g2b301f53e
spi_bus_add_device() causes CS glitch
spi_bus_add_device() causes CS glitch
& I also believe that IDF CAN should be fixed.
Re: spi_bus_add_device() causes CS glitch
you might want to give more information. Are you using Arduino or esp-idf ?
you might want to share your code for the rest to check to see if your doing things right.
you might want to share your code for the rest to check to see if your doing things right.
Re: spi_bus_add_device() causes CS glitch
esp-idf as posted version.
Code: Select all
void _can_spi_initialise()
{
esp_err_t ret;
spi_bus_config_t hwciCANSpiBusCfg={};
//-- SPI BUS
hwciCANSpiBusCfg.mosi_io_num = GPIO_CAN_MOSI;
hwciCANSpiBusCfg.miso_io_num = GPIO_CAN_MISO;
hwciCANSpiBusCfg.sclk_io_num = GPIO_CAN_SCLK;
hwciCANSpiBusCfg.quadwp_io_num = -1; // Not used
hwciCANSpiBusCfg.quadhd_io_num = -1; // Not used
hwciCANSpiBusCfg.max_transfer_sz = 16;
hwciCANSpiBusCfg.flags = 0;
//-- Initialise the SPI bus
ret=spi_bus_initialize(SPI_HOST_CAN, &hwciCANSpiBusCfg, DMA_CAN_CHANNEL);
ESP_ERROR_CHECK(ret);
//-- SPI CAN DEVICES
spi_device_interface_config_t hwciDevCfgCAN0={};
hwciDevCfgCAN0.clock_speed_hz=CAN_SPI_CLOCK; // Limited to 10MHz by the MCP2515 (Full duplex via GPIO matrix otherwise 26MHz)
hwciDevCfgCAN0.mode=CAN_SPI_MODE; // SPI mode 0 (MCP2515 supports modes 0,0 & 1,1)
hwciDevCfgCAN0.queue_size=5; // Can queue upto 5 transactions at a time
//hwciDevCfgCAN0.input_delay_ns = 50; // Allows us to work at 10MHz but also reduces CAN throughput (extra setup?)
#if CAN1 == CAN_MCP2515
spi_device_interface_config_t hwciDevCfgCAN1={};
hwciDevCfgCAN1 = hwciDevCfgCAN0;
hwciDevCfgCAN1.spics_io_num = GPIO_CAN_CS1;
ret=spi_bus_add_device(SPI_HOST_CAN, &hwciDevCfgCAN1, &spiCANDeviceHandle[1]);
ESP_ERROR_CHECK(ret);
#endif
return;
} //-- endfn _can_spi_initialise() --//
& I also believe that IDF CAN should be fixed.
Re: spi_bus_add_device() causes CS glitch
Question, in your code, why are you not adding hwciDevCfgCAN0 ?
spi_bus_add_device(SPI_HOST_CAN, &hwciDevCfgCAN0, &spiCANDeviceHandle[1]);
spi_bus_add_device(SPI_HOST_CAN, &hwciDevCfgCAN0, &spiCANDeviceHandle[1]);
Re: spi_bus_add_device() causes CS glitch
CAN0 SPI was used in an earlier hardware configuration. Now I use ESP CAN. Its auto so no worries.
& I also believe that IDF CAN should be fixed.
Re: spi_bus_add_device() causes CS glitch
Have you tried setting the gpio high before you call spi_bus_add_device? Also this will set the cs to gpio0 if you don't set it to -1
Code: Select all
spi_device_interface_config_t hwciDevCfgCAN0={}
Re: spi_bus_add_device() causes CS glitch
Thanks all. Turns out to be a typo in board configuration settings #if #elif. Essentially this resulted in VSPI and HSPI channels being given the same CS pin.
All working now.
All working now.
& I also believe that IDF CAN should be fixed.
Who is online
Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 125 guests