7 years, 11 months ago.

Seeed CAN_BUS Shield and the FRDM K64F

Hello,

I am trying to get the Seeed CAN-BUS Shield working with the KRDM K64F. Has anyone been successful with this? In paticular, what are the pin assignments for the CAN_SEEED class constructor?

Regards,

Tom Doyle

1 Answer

7 years, 11 months ago.

Hi Tom. Do not own this shield but does this help ?

https://developer.mbed.org/users/Just4pLeisure/code/SEEED_CAN/file/fd026fcfde94/seeed_can.h

/** A can bus client, used for communicating with Seeed Studios' CAN-BUS Arduino Shield.
 */
class SEEED_CAN
{
public:
    /** Seeed Studios CAN-BUS Shield Constructor - Create a SEEED_CAN interface connected to the specified pins.
     *
     *  The Seeed Studio CAN-BUS shield is an Arduino compatible shield and connects to the FRDM-KL25Z SPI0 interface using pins PTD2 (mosi) PTD3 (miso) PTD1 (clk). The Active low chip select normally connects to the FRDM-KL25Z's PTD0 pin, but there is an option on the Seeed Studio CAN-BUS shield to connect to the PTD5 pin. The CAN-BUS shield uses the FRDM-KL25Z's PTD4 pin for its (active low) interrupt capability. The defaults allow you to plug the Seeed Studios' CAN-BUS Shield into a FRDM-KL25Z mbed and it to work without specifying any parameters.
     *
     *  @param ncs Active low chip select, @b default: @p SEEED_CAN_CS is FRDM-KL25Z PTD0 pin (p9 on LPC1768).
     *  @n If you change the link on the Seeed Studios CAN-BUS shield you should use a value of SEEED_CAN_IO9 or PTD5 instead.
     *  @param irq Active low interrupt pin, @b default: @p SEEED_CAN_IRQ is FRDM-KL25Z PTD4 pin (p10 on LPC1768).
     *  @param mosi SPI Master Out, Slave In pin, @b default: @p SEEED_CAN_MOSI is FRDM-KL25Z PTD2 pin (p11 on LPC1768).
     *  @param miso SPI Master In, Slave Out pin, @b default: :p SEEED_CAN_MISO is FRDM-KL25Z PTD3 pin (p12 on LPC1768).
     *  @param clk SPI Clock pin, @b default: @p SEEED_CAN_MISO is FRDM-KL25Z PTD1 pin (p13 on LPC1768).
     *  @param spiBitrate SPI Clock frequency, @b default: @p 1000000 (1 MHz).
     */
#if defined MKL25Z4_H_                                                  // defined in MKL25Z4.h
    SEEED_CAN(PinName ncs=SEEED_CAN_CS, PinName irq=SEEED_CAN_IRQ, PinName mosi=SEEED_CAN_MOSI, PinName miso=SEEED_CAN_MISO, PinName clk=SEEED_CAN_CLK, int spiBitrate=1000000);
#elif defined __LPC17xx_H__                                             // defined in LPC17xx.h
    SEEED_CAN(PinName ncs=p9, PinName irq=p10, PinName mosi=p11, PinName miso=p12, PinName clk=p13, int spiBitrate=1000000);
#else                                                                   // No default constructor for other...
    SEEED_CAN(PinName ncs, PinName irq, PinName mosi, PinName miso, PinName clk, int spiBitrate=1000000);
#endif

Thanks for the reply. I had found the seeed_can.h information but was still not able to get the CAN-Bus shield to work. I'll keep trying.

Regards,

Tom

posted by Tom Doyle 13 May 2016

Tom - please post the pinout you are using now in your code.

The pinout you have posted looks to be correct when compared against the shield schematic:

http://www.seeedstudio.com/wiki/images/7/78/CAN-BUS_Shield_v0.9b.pdf

However, the baud rate is for the SPI interface speed and not the baud rate of the CAN Bus interface. Can you try with the SPI value posted in the API ?

  • @param spiBitrate SPI Clock frequency, @b default: @p 1000000 (1 MHz). int spiBitrate=1000000
posted by Sanjiv Bhatia 13 May 2016

SEEED_CAN can(D10, D2, D11, D12, D13, 125000);

posted by Tom Doyle 13 May 2016

My bad. However, nothing changed with I set the SPI clock to the default.

posted by Tom Doyle 14 May 2016