Forum Discussion
Hello Sir,
Thank you for your prompt response.
This is the timing diagram from my logic analyzer, which confirms that the chip select (CS) line remains low throughout the entire SPI transaction. Each command, address, and data byte is transmitted in 8-bit segments. There's an observed delay of approximately 11.8 µs between bytes, which, according to various sources, is within normal expectations. The SPI clock operates continuously during each 8-bit transfer, and the CS line stays low for the full duration of the transaction, encompassing command, address, and data phases.
In my Qsys design, the SPI clock was initially set to 10 MHz but now it is 1 MHz : MCP2515's maximum supported frequency is 10 MHz. Additionally, SPI mode 0,0 has been selected, as supported by the MCP2515.
I have two specific concerns:
1. Chip Select Behavior: Initially, I used the macro:
IOWR_ALTERA_AVALON_SPI_SLAVE_SEL(SPI_BASE, SPI_SLAVE_SEL);
However, this caused the chip select line to toggle every 8 bits. To address this, I switched to using the alt_avalon_spi_command function, which maintains the chip select line low throughout the entire transaction, ensuring proper communication with the MCP2515.
2. Utilizing HPS CAN Controller Without DDR: Our custom Cyclone V SoC board lacks DDR memory, preventing the use of a full-fledged embedded Linux system. I'm considering leveraging the HPS-side CAN controller by writing a bare-metal program that operates from the internal SRAM (approximately 64 KB). Is this approach feasible given the memory constraints? If so, could you provide any sample programs or guidance on implementing this?
Now for mcp2515, I believe the software setup is correct, but to rule out hardware issues, I've ordered additional MCP2515. Any insights or sample code you can share would be immensely helpful.
Thank you
Hi Nitin123,
Thanks for reviewing the waveform and agree with your statement that the SPI transaction looks healthy.
To answer to your concerns:
- Chip Select Behavior:
Yes, you are correct to apply the alt_avalon_spi_command function.
It is recommended when you are not planning to write your own drivers. - Utilizing HPS CAN Controller Without DDR:
Sorry, but we don’t have a MCP2515 setup to run this.
We are applying our experience of interacting SPI Host soft IP with other SPI peripherals to support your use case.
- Concern on Hardware Issue
Agree, that is a valid perspective to take account of.
Since the SPI transaction from Master looks valid, we should investigate from the Slave too.
Here are some MCP2515 traits that you might be interested:
(Note that, we strongly advice to approach Microchip on debugging MCP2515.
Our expertise is up to generic SPI transaction only, and also new to the MCP2515.)
- Write-Readback experiment
Have you tried Read back the same MCP2515 0x31 address?
Or run a simple write-readback experiment on any MCP2515 control register when under Configuration Mode? - Configuration Mode upon power-up & Normal Mode
Could it be possible that you need to switch to Normal Mode before using any of the TX Buffer? - LOAD TX BUFFER instruction
There is a dedicated instruction that writes to address 0x31,
Please give it a try too.