Jump to content
  • 0

Compile Error CAN-Bus OBD-II Reader with Uno32


keithkyle

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.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...