Page 14 of 18

Re: About the CAN controller.

Posted: Fri Mar 23, 2018 6:19 pm
by jcsbanks
If I recall, you might need to add this as a global (outwith a function in your c file, substituting your desired values). I am not sure if the example was intended to pick up these from menuconfig but it looked like it didn't.

Code: Select all

CAN_device_t CAN_cfg = {
	.speed=CAN_SPEED_500KBPS,		// CAN Node baudrade
	.tx_pin_id = GPIO_NUM_13,		// CAN TX pin
	.rx_pin_id = GPIO_NUM_14,		// CAN RX pin
	.rx_queue=NULL,					// FreeRTOS queue for RX frames
};

Re: About the CAN controller.

Posted: Mon Mar 26, 2018 10:21 pm
by Hollie_Maea
I'm still trying to get this code to work. I decided to add the third party components as Rudy suggested. That seems to be working great and I can turn on CAN and configure it in the menuconfig.

I took an example project that I had running on the chip (simply blinks the LED) and tried to just add the CAN code from Thomas' demo--I added include statements for CAN.h and CAN_config.h plus the task_CAN function from the demo and this line in the app main:

xTaskCreate(&task_CAN, "CAN", 2048, NULL, 5, NULL);


However, when I build the app, I get the following error:

C:/msys32/home/BobS/esp/blink/build/main\libmain.a(blink.o):(.literal.task_CAN+0x0): undefined reference to `CAN_cfg'


Any ideas what I'm missing? Thanks!

Re: About the CAN controller.

Posted: Tue Apr 10, 2018 3:42 pm
by jcsbanks
I think you are missing what I put in the post above yours?

Re: About the CAN controller.

Posted: Thu Apr 12, 2018 12:44 pm
by Markus Becker
Has anyone used the acceptance filters?

For me, whatever i write to MODULE_CAN->MBX_CTRL.ACC.CODE[] and MODULE_CAN->MBX_CTRL.ACC.MASK[] seems to have no effect at all.
All messages get through, even if i set the mask registers all to 0 directly in can.c, where they are initialized to 0xff (dont care) by default.

What did i miss?

Best
Markus

Re: About the CAN controller.

Posted: Thu Apr 12, 2018 12:52 pm
by jcsbanks
Not tried them because SJA1000 even in Pelican mode only has two x 16 bit or 1 x 32 bit for filters.

I'm going to modify the receive interrupt to populate different queues depending on the CAN IDs as I need to receive on at least six different IDs. It seems common to do it in software with faster microcontrollers.

Re: About the CAN controller.

Posted: Thu Apr 12, 2018 1:21 pm
by Markus Becker
sure, setting up filtering within the isr works, but in my case the SJA1000 filters would well match my needs.
And reducing interrupts is always desirable...

Re: About the CAN controller.

Posted: Thu Apr 12, 2018 5:53 pm
by Markus Becker
ahgrrr, this was caused by myself editing an unsued source file in combination with ignoring the SJA1000 data sheet, sorry.

The acceptance filters in fact work nicely as expected.

I simply missed, that the SJA1000 needs to be in reset mode to give access to the filter registers.
To change filter settings we first need to set reset mode (MODULE_CAN->MOD.B.RM = 1;) then set filters code and mask (MODULE_CAN->MBX_CTRL.ACC.CODE[], MODULE_CAN->MBX_CTRL.ACC.MASK) and finally leave reset mode (MODULE_CAN->MOD.B.RM = 0;)

Best,
Markus

About the CAN controller on ESP WROOM 32 with VP230 micro.

Posted: Tue Apr 24, 2018 8:07 am
by Kaidou
Hi.
Does anyone have a working CAN example for the ESP WROOM 32 board with the VP230 micro?
Thanks.

Re: About the CAN controller.

Posted: Fri Apr 27, 2018 8:27 pm
by Hollie_Maea
jcsbanks wrote:I think you are missing what I put in the post above yours?
I don't think that's it. As I said, I set it up to use the esp-idf as Rudy described in his response to you on page 7. I am able to turn on the CAN module, set the pins and the speed all from the menuconfig. So that part seems to be working right. And I have the two includes:

#include "CAN.h"
#include "CAN_config.h"

So I don't see why "CAN_cfg" errors out as undefined.

Re: About the CAN controller.

Posted: Sat Apr 28, 2018 7:48 am
by jcsbanks
If you are using menuconfig I think you have to add code to use what is defined there, but I never progressed that method as all it really does is change the pins and I prefer to do that in my code when changing between test boards for quicker compilation.

I think it could be the same issue because manually defining CAN_cfg fixes errors that sound similar and if I recall it was the only fix needed to get the example to compile - I did not see a simpler way to get the example project to build. I do not have a ready made example based on the example project as my project is now much larger and altered.