Post by ssnow on Dec 2, 2016 13:58:36 GMT
Hi all,
I've got a ShieldBuddy here which I'm experimenting with using the Arduino IDE and I can't seem to get the CAN transmit to work. I used the User Manual to create a simple sketch:
My serial output is
Which would indicate that the initialisation works fine, then the first time around loop (i = 0) the CAN send line is executed OK but the second time around (i = 1) the program hangs at the CAN send line. I don't see any messages on my CAN monitor.
What am I missing here? Is there a way to know if a message was transmitted successfully?
Cheers,
Stuart
I've got a ShieldBuddy here which I'm experimenting with using the Arduino IDE and I can't seem to get the CAN transmit to work. I used the User Manual to create a simple sketch:
/*** Don't worry, the normal Arduino setup() and loop() are below this block! ***/
/* LMU uninitialised data */
StartOfUninitialised_LMURam_Variables
/* Put your LMU RAM fast access variables that have no initial values here e.g. uint32 LMU_var; */
EndOfUninitialised_LMURam_Variables
/* LMU uninitialised data */
StartOfInitialised_LMURam_Variables
/* Put your LMU RAM fast access variables that have an initial value here e.g. uint32 LMU_var_init = 1; */
EndOfInitialised_LMURam_Variables
/* If you do not care where variables end up, declare them here! */
uint8_t i;
/*** Core 0 ***/
void setup()
{
SerialASC.begin(115200);
SerialASC.println("Setting pins");
pinMode(LED_BUILTIN, OUTPUT);
SerialASC.println("Init CAN0");
CAN0_Init(500000);
SerialASC.println("Setup CAN msgs");
CAN0_TxInit(0x100, 0x7FFFFFFFUL, 8, 11, 0); // (msg ID, acceptance mask, DLC, 11 or 29 bit ID, msg object to use)
SerialASC.println("Booted");
}
void loop()
{
SerialASC.println(i++);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
CAN0_SendMessage(0x100, 0x12340000, 0x9abc0000, 8); // (msg ID, 32 bits low data, 32 bits high data, DLC)
delay(100);
}
/*** Core 1 ***/
/* CPU1 Uninitialised Data */
StartOfUninitialised_CPU1_Variables
/* Put your CPU1 fast access variables that have no initial values here e.g. uint32 CPU1_var; */
EndOfUninitialised_CPU1_Variables
void setup1()
{
}
void loop1()
{
}
/*** Core 2 ***/
/* CPU2 Uninitialised Data */
StartOfUninitialised_CPU2_Variables
/* Put your CPU2 fast access variables that have no initial values here e.g. uint32 CPU2_var; */
EndOfUninitialised_CPU2_Variables
/* CPU2 Initialised Data */
StartOfInitialised_CPU2_Variables
/* Put your CPU2 fast access variables that have an initial value here e.g. uint32 CPU2_var_init = 1; */
EndOfInitialised_CPU2_Variables
void setup2()
{
// put your setup code for core 2 here, to run once:
}
void loop2()
{
// put your main code for core 2 here, to run repeatedly:
}
My serial output is
Setting pins
Init CAN0
Setup CAN msgs
Booted
0
1
Which would indicate that the initialisation works fine, then the first time around loop (i = 0) the CAN send line is executed OK but the second time around (i = 1) the program hangs at the CAN send line. I don't see any messages on my CAN monitor.
What am I missing here? Is there a way to know if a message was transmitted successfully?
Cheers,
Stuart