Feather M4 CAN bus commands driving NeoPXL8

Hi folks,
I'm trying to use the CAN1 bus and NeoPXL8 concurrently on my M4 CAN setup. Eventually, I plan to use the CAN commands to command led animations. I believe I'm hitting a conflict between the two libraries (ACANFD_FeatherM4CAN.h and Adafruit_NeoPXL8.h). Individually they work fine. I can receive CAN commands with the first, and light up leds with the other.

But the moment I call them in the same file, the M4 freezes up. It's serial communication stops and it does neither of the functions. Is there any setting that I'm forgetting?

Code below:

#define CAN0_MESSAGE_RAM_SIZE (0)
#define CAN1_MESSAGE_RAM_SIZE (1728)
#include <ACANFD_FeatherM4CAN.h>

#define NUM_LEDS 10 // NeoPixels PER STRAND, total number is 8X this!
#define COLOR_ORDER NEO_WRGB // NeoPixel color format (see Adafruit_NeoPixel)
#include <Adafruit_NeoPXL8.h>


//-----------------------------------------------------------------

void setup () {

//--- Note: for compatibility with releases 1.x, insert ACANFD_FeatherM4CAN_Settings::CLOCK_48MHz
// as first argument, 48 MHz clock was the only available clock in release 1.x
ACANFD_FeatherM4CAN_Settings settings (ACANFD_FeatherM4CAN_Settings::CLOCK_48MHz, 500 * 1000, DataBitRateFactor::x1) ;


pinMode(PIN_CAN_STANDBY, OUTPUT);
digitalWrite(PIN_CAN_STANDBY, false); // turn off STANDBY
pinMode(PIN_CAN_BOOSTEN, OUTPUT);
digitalWrite(PIN_CAN_BOOSTEN, true); // turn on booster
int8_t pins[8] = { 13, 12, 11, 10, SCK, 5, 9, 6 };

Adafruit_NeoPXL8 leds(NUM_LEDS, pins, COLOR_ORDER);


while (!Serial) {
delay (50) ;
digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
}

const uint32_t errorCode = can1.beginFD (settings) ;
if (0 == errorCode) {
Serial.println ("can configuration ok") ;
}
else{
Serial.print ("Error can configuration: 0x") ;
Serial.println (errorCode, HEX) ;
}
}


void loop () {
//--- Receive frame
CANFDMessage message ;

if (can1.receiveFD0 (message)) {
if ((message.type==message.CAN_DATA) && !message.ext && (message.id == 0x15E)) {
Serial.println(message.data[7]);
}
}
}

what microcontroller does a M4-feather use?

It might be that the neopixel-library wants to use the same interrupts as he can bus or is blocking interrupts when sending out data.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.