SAME70 CAN Issues - Page 1
Forum section: electronics / general

author: jars121
author_rank: Regular Contributor
timestamp: October 22, 2020, 12:02:45 am
content: Hi,ContextI'm working with a SAME70Q21 (Rev B), for which I have already developed and tested a range of interfaces (e.g. I2C, SPI, UART, Ethernet, etc.). I'm currently trying to get a barebones CAN example running using ASF 3.49.1, which has had me absolutely stumped for over a week. I've got an open support ticket with Microchip, but they've not responded for over a week, so I figured I'd put this up here in the hope that someone may have successfully implement CAN on a SAME70 device or is able to spot an error in the code. Unfortunately there isn't an out of the box MCAN example for the SAME70, the closest available from the ASF is for the SAMV71. As such, I've created a new empty ASF 3.49.1 project for the SAME70-XPLD and copied the pertinent configuration, setup and application content into it from the SAMV71 example.Rather than paste a huge chunk of code, which is hard to understand in an inline format, I've attached the entire project, including the source and the Atmel Studio project files.The problemDespite my best efforts to copy the structure and content of the SAMV71 ASF CAN example exactly, I'm not able to get any CAN activity (either TX or RX) on the SAME70. I've run the code both on my custom PCB and on a SAME70-XPLD board, both of which seem to run the code without issue, but the MCAN0_INT0_Handler() interrupt is never called, and the manual TX appears to execute without issue, yet no output is observed on the CANTX0 pin. Similarly, manually polling the RX buffer always indicates no data has been received.I have verified the CANH/CANL signals with an oscilloscope, so I'm confident that the bus is not the issue. Similarly, I've verified the corresponding RX signal out of the CAN transceiver (i.e. the signal at the SAME70 CANRX0 pin), so I don't believe there's an issue external to the SAME70 itself. To make absolutely sure that there wasn't an issue on the RX pin, I commented out the CAN code an instead setup the CANRX0 pin as a GPIO input with an interrupt handler, and when I commenced remote CAN transmission the GPIO interrupt handler was called as expected. As such, I'm fairly certain that the issue here is with the MCAN interface/driver and/or my configuration.I'm at somewhat of a loss as to how to resolve this issue. As mentioned above, I've got an outstanding support case with Microchip and have provided project files, code snippets, oscilloscope screenshots, etc., but I can't continue to wait for their response. I've posted a similar thread on AVRFreaks but again, I've not had any response.Any guidance or clarification would be greatly appreciated! I'm in correspondence with another SAME70 user who is also really struggling to get basic CAN functionality working on this device, so hopefully we're able to collectively put together a working example. I'll be sure to update this post regardless once an outcome has been reached.

author: ataradov
author_rank: Super Contributor
timestamp: October 22, 2020, 08:38:40 pm
content: On a very quick look at the code, I see that you have selected UPLL as a clock source for the PCK5, which clocks the CAN controller. Yet your code never enables the UPLL.Also, ASF CAN examples are known to work.

author: jars121
author_rank: Regular Contributor
timestamp: October 22, 2020, 11:57:32 pm
content: Alex I really owe you one.I had initially used the standard clock configuration (per the SAMV71 example), but had subsequently changed to UPLL and somehow missed enabling it. I've spent the last day or so sifting through the register values in the IO panel of Atmel Studio trying to understand where I'd gone wrong and of course it's as simple is enabling the right clock.I've just enabled UPLL and transmitted some frames on the bus and the MCAN_RX_FIFO_0_NEW_MESSAGE interrupt was called immediately as desired.Thanks again!