CANhack.de CAN-Interface RKS+CAN
Diesel technology, engine technology, vehicle diagnostics, repair & maintenance.

µC + 2x MCP2515 for filtering

 
New Topic Reply 🔗 🖨 CANhack.de - Index » Microcontrollers and Electronics, Programming
Author Message
shavenne
CAN-Profi
CAN-Profi


Joined: 04/27/2015
Posts: 37
Karma: +6 / -0   Thank you, like it!
Location: Paderborn

CAN Support

Post20-04-2017, 0:07    Subject: µC + 2x MCP2515 for filtering Quote

Hi!

I'm a bit puzzled right now.

I got myself an STM32 (specifically a Nucleo F303K8)) and connected two MCP2515s to it. So far, sending and receiving are working perfectly.

What I actually want to achieve is to connect a head unit to one MCP2515 and the corresponding display to the other. What one receives, the other transmits, and vice versa.
I want to be able to see, for one thing, which device each message originates from, and also be able to filter out individual IDs. That's the theory. It works fine in principle, BUT: As soon as a large amount of data arrives in quick succession (for example, when opening a large menu), messages are dropped, and of course, the menu fails to open.
It seems like he might not be able to retrieve the RX buffer fast enough. No matter how I try to optimize it (creating a custom TX buffer, giving higher priority to receiving, disabling serial output, etc.), nothing seems to help. It's running so unreliably icon_sad.gif.

Before I continue trying to optimize every little detail to get this working: Is my plan even feasible? What I'm doing right now would only be a "nice-to-have" for me, and I don't necessarily need it to be 100% functional, but I thought that if I could filter out specific data for the target device, it might simplify future actions. Ideas?

Regards,
Sven.


Last edited on 20-04-2017, 0:09, edited 2 times in total.
Back to top Profile PM
Zampan0
CAN-Profi
CAN-Profi


Joined: 06/28/2016
Posts: 30
Karma: +20 / -0   Thank you, like it!


CAN Support

Post21-04-2017, 7:49    Subject: µC + 2x MCP2515 for filtering Quote

Have you connected each interrupt pin of the MCP2515 to a separate input pin of the STM?
Each MPC reports its hardware status, indicating whether there is any data in the buffer.
I haven't lost a single frame.
Back to top Profile PM
GerdJ
CAN-Profi
CAN-Profi


Joined: 09/08/2014
Posts: 45
Karma: +12 / -0   Thank you, like it!


Premium Support

Post21-04-2017, 8:07    Subject: µC + 2x MCP2515 for filtering Quote

Hello,

"What you're planning to do, my FIS blocker does the same thing; it sits between (in my case) the radio and the car's infotainment system on the CAN bus. It's based on an STM32F4, which has 2 built-in CAN interfaces." So, you save yourself all the SPI hassle.

I have never experienced dropped frames. The STM32 runs at 186MHz, and the CAN interfaces are polled using interrupts.

Do you use polling, any wait statements, or possibly unnecessary and slow serial outputs?
Take a look at an STM32F4 Discovery board.
Back to top Profile PM
CAN-Diagnose
Administrator
Administrator
Avatar-CAN-Diagnose

Joined: 06/07/2011
Posts: 573
Karma: +29 / -0   Thank you, like it!
Location: Ländle



Post21-04-2017, 9:51    Subject: µC + 2x MCP2515 for filtering Quote

The STM32 is actually fast enough that, with proper programming, no messages should be lost. icon_wink.gif
Dipl.-Ing. (FH) Rainer Kaufmann - Embedded Software Freelancer
System RKS+CAN: CANHack.de CAN-Bus Interface
Back to top Profile PM WWW
shavenne
CAN-Profi
CAN-Profi


Joined: 04/27/2015
Posts: 37
Karma: +6 / -0   Thank you, like it!
Location: Paderborn

CAN Support

CAN-Diagnose likes this.
Post21-04-2017, 10:34    Subject: µC + 2x MCP2515 for filtering Quote

I think I found the problem last night, late in the evening. It was probably not a software problem, but rather a connection problem between a transceiver and its MCP2515... a breadboard, you know icon_wink.gif. I'll keep an eye on that.

I observed with a Saleae Logic analyzer that there was complete chaos on the SPI bus at a random point in time, but no new interrupts were coming from the MCP, which suggested that my microcontroller was repeatedly requesting free TX buffer slots, but apparently, none were available.

But thank you for the suggestions icon_smile.gif.


Last edited on 21-04-2017, 10:47, edited 1 time in total.
Back to top Profile PM
GerdJ
CAN-Profi
CAN-Profi


Joined: 09/08/2014
Posts: 45
Karma: +12 / -0   Thank you, like it!


Premium Support

Post21-04-2017, 10:42    Subject: µC + 2x MCP2515 for filtering Quote

Breadboards are icon_smile.gif so often the problem.

Just a tip: Take a look at the Teensy 3.6. It's Arduino compatible, has 2 CAN interfaces, an SD card slot, is small, and very, very fast. You can simply connect two 3.3V CAN transceivers to it and load the software for dual CAN functionality. It's hard to make it any simpler.
Back to top Profile PM
shavenne
CAN-Profi
CAN-Profi


Joined: 04/27/2015
Posts: 37
Karma: +6 / -0   Thank you, like it!
Location: Paderborn

CAN Support

Post21-04-2017, 10:49    Subject: µC + 2x MCP2515 for filtering Quote

The Nucleo board also has a CAN interface, but I'm not entirely clear on how to get the timing right with it. I need something quite unusual for the Opel infotainment system, specifically 95.238 kbps.
Back to top Profile PM
New Topic Reply 🔗 🖨 CANhack.de - Index » Microcontrollers and Electronics, Programming
Similar articles and topics
Topic Forum
No new posts Arduino + Can Bus Shield / PID Filtern Microcontrollers and Electronics, Programming
No new posts RCD 320 : CAN Simulation mit AVR und MCP2515 CAN Bus General
No new posts CAN-Bus auswerten mit MCP2515 und RaspberryPi Microcontrollers and Electronics, Programming
No new posts Arduino mit MCP2515 als Steuerung Microcontrollers and Electronics, Programming
Jump to:  
You cannot post new topics in this forum.