About the CAN controller.

jcsbanks
Posts: 305
Joined: Tue Mar 28, 2017 8:03 pm

Re: About the CAN controller.

Postby jcsbanks » Fri Mar 23, 2018 6:19 pm

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
};

Hollie_Maea
Posts: 6
Joined: Thu Mar 22, 2018 10:45 pm

Re: About the CAN controller.

Postby Hollie_Maea » Mon Mar 26, 2018 10:21 pm

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!

jcsbanks
Posts: 305
Joined: Tue Mar 28, 2017 8:03 pm

Re: About the CAN controller.

Postby jcsbanks » Tue Apr 10, 2018 3:42 pm

I think you are missing what I put in the post above yours?

Markus Becker
Posts: 22
Joined: Fri Mar 02, 2018 3:24 pm

Re: About the CAN controller.

Postby Markus Becker » Thu Apr 12, 2018 12:44 pm

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

jcsbanks
Posts: 305
Joined: Tue Mar 28, 2017 8:03 pm

Re: About the CAN controller.

Postby jcsbanks » Thu Apr 12, 2018 12:52 pm

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.

Markus Becker
Posts: 22
Joined: Fri Mar 02, 2018 3:24 pm

Re: About the CAN controller.

Postby Markus Becker » Thu Apr 12, 2018 1:21 pm

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...

Markus Becker
Posts: 22
Joined: Fri Mar 02, 2018 3:24 pm

Re: About the CAN controller.

Postby Markus Becker » Thu Apr 12, 2018 5:53 pm

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

Kaidou
Posts: 1
Joined: Tue Apr 24, 2018 8:04 am

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

Postby Kaidou » Tue Apr 24, 2018 8:07 am

Hi.
Does anyone have a working CAN example for the ESP WROOM 32 board with the VP230 micro?
Thanks.

Hollie_Maea
Posts: 6
Joined: Thu Mar 22, 2018 10:45 pm

Re: About the CAN controller.

Postby Hollie_Maea » Fri Apr 27, 2018 8:27 pm

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.

jcsbanks
Posts: 305
Joined: Tue Mar 28, 2017 8:03 pm

Re: About the CAN controller.

Postby jcsbanks » Sat Apr 28, 2018 7:48 am

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.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 31 guests