Closed brainstorm closed 1 year ago
@gamelaster Following up over here from our Telegram discussion... you meant something like this?:
diff --git a/drivers/lhal/include/bflb_gpio.h b/drivers/lhal/include/bflb_gpio.h
index e4f410d8..1417c4b0 100644
--- a/drivers/lhal/include/bflb_gpio.h
+++ b/drivers/lhal/include/bflb_gpio.h
@@ -123,6 +123,7 @@
#define GPIO_FUNC_AUDAC_PWM (25 << GPIO_FUNC_SHIFT)
#define GPIO_FUNC_JTAG (26 << GPIO_FUNC_SHIFT)
#define GPIO_FUNC_PEC (27 << GPIO_FUNC_SHIFT)
+#define GPIO_FUNC_ISO11898 (28 << GPIO_FUNC_SHIFT)
#define GPIO_FUNC_CLKOUT (31 << GPIO_FUNC_SHIFT)
#elif defined(BL606P) || defined(BL808)
#define GPIO_FUNC_SDH (0 << GPIO_FUNC_SHIFT)
diff --git a/examples/peripherals/iso11898/iso11898_selftest/main.c b/examples/peripherals/iso11898/iso11898_selftest/main.c
index 7298d861..d2b6318a 100644
--- a/examples/peripherals/iso11898/iso11898_selftest/main.c
+++ b/examples/peripherals/iso11898/iso11898_selftest/main.c
@@ -1,4 +1,5 @@
#include "bflb_mtimer.h"
+#include "bflb_gpio.h"
#include "bflb_iso11898.h"
#include "board.h"
@@ -6,7 +7,7 @@ struct bflb_device_s *iso11898;
struct bflb_iso11898_config_s cfg = {
.prescaler = 0, /*!< specifies the length of a time quantum, ranges from 1 to 63, tq=tclk*2*(prescaler+1) */
- .mode = ISO11898_MODE_LOOPBACK, /*!< specifies the CAN operating mode. @ref ISO11898_MODE_XXX */
+ .mode = ISO11898_MODE_NORMAL, /*!< specifies the CAN operating mode. @ref ISO11898_MODE_XXX */
.sample = ISO11898_SAMPLE_TRIPLE, /*!< specifies the number of sample times. @ref ISO11898_SAMPLE_XXX */
.sjw = ISO11898_SJW_2TQ, /*!< specifies the maximum number of time quanta the ISO11898 hardware is allowed to lengthen or shorten a bit to perform resynchronization. @ref ISO11898_SJW_XXX */
.bs1 = ISO11898_BS1_9TQ, /*!< specifies the number of time quanta in Bit Segment 1. @ref ISO11898_BS1_XXX */
@@ -40,9 +41,11 @@ int main(void)
{
int ret = 0;
board_init();
- board_iso11898_gpio_init();
+ //board_iso11898_gpio_init();
iso11898 = bflb_device_get_by_name("iso11898");
+ bflb_gpio_init(iso11898, GPIO_PIN_16, GPIO_FUNC_ISO11898 | GPIO_ALTERNATE );
+ bflb_gpio_init(iso11898, GPIO_PIN_17, GPIO_FUNC_ISO11898 | GPIO_ALTERNATE );
bflb_iso11898_init(iso11898, &cfg);
bflb_iso11898_set_filter(iso11898, &filter);
Can't find in the datasheet where GPIOs can be mapped on the ISO11898 &config
struct...
@brainstorm this seems to be right.
@brainstorm this seems to be right.
No, it's not :/ @gamelaster How do you map those GPIOs, 16 and 17 to the ISO11898 config?
After looking at the current SDK function state, as mentioned in the first comment:
I believe that the CAN (ISO11898 peripheral) has not seen much testing other than selftest (no actual GPIO pins output), am I right, @sakumisue?
After looking at the current SDK function state, as mentioned in the first comment:
I believe that the CAN (ISO11898 peripheral) has not seen much testing other than selftest (no actual GPIO pins output), am I right, @sakumisue?
No,just not updated.
Updated now.
I think that you closed this issue a bit too fast? I noticed your changes on those commit lines with unrelated commit message ... please reopen this issue as it's not solved yet 👇🏻 ?
When I plug my oscilloscope to GPIO 14 and GPIO 15 and make the following changes to the example code to trigger a continuous sending of CAN packets:
diff --git a/examples/peripherals/iso11898/iso11898_filter/main.c b/examples/peripherals/iso11898/iso11898_filter/main.c
index 1b3d0ad0..99e92c10 100644
--- a/examples/peripherals/iso11898/iso11898_filter/main.c
+++ b/examples/peripherals/iso11898/iso11898_filter/main.c
@@ -75,9 +75,9 @@ int main(void)
bflb_iso11898_txint_mask(iso11898, false);
bflb_iso11898_rxint_mask(iso11898, false);
bflb_irq_enable(iso11898->irq_num);
- bflb_iso11898_send(iso11898, &msg_tx, 1000);
while (1) {
+ bflb_iso11898_send(iso11898, &msg_tx, 1000);
bflb_mtimer_delay_ms(2000);
}
}
The oscilloscope does not register no signals:
Can you explain why that would be? Have you tested it yourself at your end after making those changes to the SDK and recompiling/flashing @sakumisu?
Btw, thanks for the making the make flash
command work, that's good UX progress! :)
No problem.
Can you hook up a logic analyser on IO14 and IO15 and verify that there's indeed CAN compatible signals in there and not just UART messages?
This has already tested before, and i think you should check by yourself, i have no time to help you now.
And i see you do not use another can module, it does not work. So no signals is right.
Thanks for re-opening this issue. Even if there's no CAN transceiver attached, there should be signals showing up on the oscilloscope anyway.
Thanks for re-opening this issue. Even if there's no CAN transceiver attached, there should be signals showing up on the oscilloscope anyway.
Follow our ic designer, he said.
Follow our ic designer, he said.
Excuse me, I cannot understand what you just said: what do you mean?
I've worked successfully with other ICs that support CAN (i.e TWAI on Espressif) and the signals before and after the transceiver IC (i.e TJA1043) can be seen on RXD/TXD as well as CAN_H/CAN_L pins, here's my scope dissecting arbitrary CAN packets on both ends (of a transceiver) attached to an ESP32S2:
Can you show a similar result with your ISO11898 peripheral code? Is the BL616 SDK well tested (aside from UART debug) for this peripheral? Does it output on-spec signals on the pins you recently (a week ago?) defined in the SDK (GPIO_PIN_14
and GPIO_PIN_15
)?
Yes, but you need can transceiver. i think this issue is done.
You can use any gpio pin for can tx and rx.
SDK defined is GPIO14 and GPIO15
Yes, but you need can transceiver. i think this issue is done.
Nope, you don't.
I've just posted a screenshot of my oscilloscope telling you otherwise, can you please test it on your end without a CAN transceiver attached? It should display the signals shown above in yellow and blue (roughly). The output in pink was either CAN_H/CAN_L transceiver output (cleaner and on-spec for CAN).
SDK defined is GPIO14 and GPIO15
My mistake, I meant those and those were the ones I probed on the BL616 test above ☝🏻 , editing the comment where I referred to those pins wrongly......
I have said, if you try without transceiver IC, it has no signals.
I have said, if you try without transceiver IC, it has no signals.
I understood fully what you said here and I'm telling you it makes no sense because the latest oscilloscope photo is showing you the opposite... what more evidence do you need?
Your test is other ics not ours.
You test is other ics not ours.
Fine, fair enough, I'll attach a transceiver and come back to you with more evidence, I hope I'm wrong :)
And your other ic test with transceiver IC, you can remove them to test.
If you use transceiver IC,it will work.
Going through the CAN (ISO11898) example, it seems like the pins init function,
board_iso11898_gpio_init()
, is commented out in the SDK itself and therefore no pins are assigned anywhere?