• 0
keithkyle

Compile Error CAN-Bus OBD-II Reader with Uno32

Question

Trying to compile demo from Sparkfun. It compiles properly with Arduino software. I'm new to Arduino. Not sure what I need to modify in the library.

https://github.com/sparkfun/CAN-Bus_Shield

Text from the demo code:

"This example sketch works with the CAN-Bus shield from SparkFun Electronics.
It enables the MCP2515 CAN controller and MCP2551 CAN-Bus driver, and demos
using the chips to communicate with a CAN-Bus.
Resources:
Development environment specifics:
Developed for Arduino 1.6.5
Based off of original example ecu_reader_logger by:
Sukkin Pang
SK Pang Electronics www.skpang.co.uk"

Error is:

C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:28:24: fatal error: util/delay.h: No such file or directory
compilation terminated.

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi keithkyle,

As you noticed, it was built for Arduino 1.6.5, and since chipKIT boards do not specifically implement avr components, you can run into these sorts of errors every now and then. 

Within MPIDE, the util/delay.h library header file does exist, but I personally don't know how to make MPIDE find it nicely for you. Luckily, we should be able to nicely change the few lines of code that does need this particular library to an alternate delay that is natively supported in MPIDE.

What you would need to do is find the mcp2515.c file and open it up with some sort of text editor such as notepad++. You will then need to either comment out or delete the
"#include <util/delay.h> that is around line 30 of that file.  Then you will need to go both lines 149 (or so) and 327 (or so) and change the "_delay_us" portion of the line to instead say "delayMicroseconds" while leaving everything else alone in those lines. Save your changes and then see what MPIDE thinks when you try to compile the program.

Let me know if you have any more questions.

Thanks,
JColvin

Share this post


Link to post
Share on other sites
  • 0

Hi JColvin,

Thank you. Did the edit. Now, for the next stack of errors:

C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c: In function 'spi_putc':
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:53:2: error: 'SPDR' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:53:2: note: each undeclared identifier is reported only once for each function it appears in
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:56:12: error: 'SPSR' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:56:23: error: 'SPIF' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c: In function 'mcp2515_init':
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:125:1: error: 'DDRB' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:135:1: error: 'DDRD' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:139:2: error: 'SPCR' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:139:13: error: 'SPE' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:139:22: error: 'MSTR' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:139:34: error: 'SPR1' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:139:44: error: 'SPR0' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:140:2: error: 'SPSR' undeclared (first use in this function)
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c: In function 'mcp2515_check_message':
C:\mpide-0150\.\hardware\pic32\libraries\CanBus\mcp2515.c:201:1: error: 'PIND' undeclared (first use in this function)

Keith

Share this post


Link to post
Share on other sites
  • 0

Hi Keith,

Sorry for not getting back to you sooner. I'm following up on your question. I was wondering if you had gone anouther route to resolve the compatibility issues with the AVR components.

 

thank you,

 

Jon

 

Edited by jpeyron

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now