Re: Using #stm32 HAL_TIM_xyz for counting pulses with timer in external clock mode
#stm32
Erwan Gouriou
Hi Pauli, If you are able to do what you want with Cube HAL then, to interface with zephyr, you just need to redefine the HAL callback (defined as weak in HAL drivr) in your zephyr application. You can check what has been done in a similar fashion on zephyr stm32 ethernet driver. HIH Cheers Erwan
On Tue, 10 Dec 2019 at 18:02, Pauli <susundberg@...> wrote: Dear all,
|
|
Using #stm32 HAL_TIM_xyz for counting pulses with timer in external clock mode
#stm32
Pauli
Dear all,
I am doing silly motor driver for worm-gear dc-motor with stm32f411e-disco board (and L298). The dc-motor has HAL-sensor for feedback - providing raising/lowering edge for every turn. Now, as the HAL sensor is attached before the worm-gear, so the RPM will be something. To have it handled with ease i was thinking to connect the HAL sensor output to STM32 as external clock input -> i can get the count from the timer register with zero load to processor. As far as i know (and have tested - it compiles) i can use the HAL_TIM_XYZ functions and they should work -> i can use them to configure timer to be in external clock mode. But how does one handle the overflow of the timer? In normal STM32 HAL code one would get interupt from this but i have no glue how to do it with Zephyr. I do know i could poll it with very little overhead, but that seems bit brute-force. Would it be easy to set up interrupt handler for timer overflow? Could somebody point out tips what would be the steps required (or just say its not doable without weeks of work)? What Zephyr source files i should look at? Any change of samples that would even have some similarity? BR, Pauli
|
|
API meeting: Agenda
Carles Cufi
Hi all,
This week we will focus on API Changes and GPIO: - Changing a stable API: - https://github.com/zephyrproject-rtos/zephyr/pull/21013 - GPIO: Update on progress - Look at the PRs with driver conversion (https://github.com/zephyrproject-rtos/zephyr/issues/18530) - Check users of GPIO APIs: https://github.com/zephyrproject-rtos/zephyr/issues/20017 - Tips for converting users can be found here: https://github.com/zephyrproject-rtos/zephyr/issues/20017#issuecomment-549315497 (thanks Peter!) - Any additional outstanding PRs to topic-gpio Additional items in the "Triage" column in the GitHub project may be discussed if time permits. If you want an item included in the meeting, please add it to the GitHub project. https://github.com/zephyrproject-rtos/zephyr/wiki/Zephyr-Committee-and-Working-Group-Meetings#zephyr-api-discussion https://github.com/zephyrproject-rtos/zephyr/projects/18 https://docs.google.com/document/d/1lv-8B5QE2m4FjBcvfqAXFIgQfW5oz6306zJ7GIZIWCk/edit Regards, Carles
|
|
Different MAC address for nrf52 when using as a controller
#bluetooth
#nrf52480
#usb
#ble
Hi,
Iam using nrf52840 DK as a BLE controller. So i compiled a hex file and loaded into it. There after when we power on am getting the bdaddr of the device as 00:00:00:00:00:00, But when i check the "bluetootctl show " command its showing the MAC address of the device.
So without modifying the bdaddr i started advertise, The scanned devices seeing the different MAC that is not equal to the address which we seen using bluetoothctl show.
So my question is
--The address which we seen in the bluetoothctl show is the correct address? or the address which we seen in scanning when the device is advertising that is correct ?
|
|
bbradley@...
I just realized I responded to you privately by accident, Lawrence. Sorry about that. I will copy the message I sent to you to the group so that the discussion is up to date.
The suggestion regarding testing the gpio with gpio_pin_read is exactly what I am currently doing, and it does indeed work well, but I had the same thought about spurious pulses potentially causing issues here. I haven't observed issues with this yet, but it certainly was a concern of mine.
|
|
Re: bt_gatt_is_subscribed - any examples?
From: users@... <users@...>
On Behalf Of Lawrence King
Sent: Thursday, December 5, 2019 4:00 PM To: users@... Subject: [Zephyr-users] bt_gatt_is_subscribed - any examples?
Dear All:
I have a similar problem to what Frank Viren is seeing in his thread “bt_gatt_notify multiple characteristics”. How to determine the pointer to the right characteristic.
When my central connects to my device I want to send it several notifications. My device has several characteristics under the primary service. When the central connects (in this case the central is either an iPhone, or an Android phone), if I simply wait 200mS after the connection and sent the notifications with bt_gatt_notify() it ‘almost’ always works. Unfortunately sometimes Android or iOS take a little longer to subscribe for notifications, hence I would like to determine if the phone is ready to receive notifications rather than simply waiting 200mS.
I hunted through the bt_ apis and found bt_gatt_is_subscribed() which looks like I can loop testing to see if the central is ready and then send the notifications. Much better than blindly waiting 200mS.
bool Check if connection have subscribed to attribute. Check if connection has subscribed to attribute value change. The attribute object can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC, or the Client Characteristic Configuration Descriptor (CCCD) which is created by BT_GATT_CCC. Return true if the attribute object has been subscribed. Parameters · conn: Connection object. · attr: Attribute object. · ccc_value: The subscription type, either notifications or indications.
OK, based on the documentation, this seems to be what I want, but the parameters are difficult for a newbie to understand: conn – yes I did declare this with BT_GATT_CHARACTERISTIC I know where it is in my source code, but how do I find a pointer to it? attr – this was automatically created with BT_GATT_CCC in the same place, but again how do I get a pointer to the attr? ccc_value – this is obviously an int, probably with definitions for the bits, but what symbolic enums or defines can I put in this parameter?
Unfortunately a google search of “bt_gatt_is_subscribed” only finds 8 results, the source code, the documentation (on the zephyr site, and on the nordic site), and 2 content aggregators. I did not find a single piece of code that calls this function, but there must be at least one call to the function in at least some test suite. bt_gatt_is_subscribed is never called in any of the zephyr/samples…
Can someone point me to an example please?
Lawrence King Principal Developer Connected Transport Market Unit +1(416)627-7302
CONFIDENTIAL: This e-mail and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. It can contain proprietary confidential information and be subject to legal privilege and/or subject to a non-disclosure Agreement. Unauthorized use, disclosure or copying is strictly prohibited. If you are not the/an addressee and are in possession of this e-mail, please delete the message and notify us immediately. Please consider the environment before printing this e-mail. Thank you.
|
|
Hi Brian:
You can always test the value of the GPIO with gpio_pin_read() in the callback, if it is 1, then the cause is a rising edge, and if it is 0 the cause was a falling edge. Unfortunately if the input is a very short pulse you could get a rising edge interrupt, but by the time you get around to reading the GPIO, it could be back to low giving you the wrong information, and the short pulse should also trigger a second interrupt. If your transitions are relatively slow the testing the GPIO is good enough.
I agree there should be a way to separate the rising and falling events. Did you try creating two call backs, one for rising, and one for falling?
gpio_pin_configure – with flags for rising edge gpio_init_callback, - rising gpio_add_callback, - rising gpio_pin_enable_callback – for rising edges
gpio_pin_configure – with flags for falling edge gpio_init_callback, - falling gpio_add_callback, - falling gpio_pin_enable_callback – for falling edges
Lawrence King Principal Developer +1(416)627-7302
From: users@... <users@...>
On Behalf Of bbradley@...
Sent: Thursday, December 5, 2019 11:16 AM To: users@... Subject: [Zephyr-users] Determining source of GPIO Interrupt on NRF52832 #gpio #nrf52832
Hello,
|
|
bt_gatt_is_subscribed - any examples?
Dear All:
I have a similar problem to what Frank Viren is seeing in his thread “bt_gatt_notify multiple characteristics”. How to determine the pointer to the right characteristic.
When my central connects to my device I want to send it several notifications. My device has several characteristics under the primary service. When the central connects (in this case the central is either an iPhone, or an Android phone), if I simply wait 200mS after the connection and sent the notifications with bt_gatt_notify() it ‘almost’ always works. Unfortunately sometimes Android or iOS take a little longer to subscribe for notifications, hence I would like to determine if the phone is ready to receive notifications rather than simply waiting 200mS.
I hunted through the bt_ apis and found bt_gatt_is_subscribed() which looks like I can loop testing to see if the central is ready and then send the notifications. Much better than blindly waiting 200mS.
bool Check if connection have subscribed to attribute. Check if connection has subscribed to attribute value change. The attribute object can be the so called Characteristic Declaration, which is usually declared with BT_GATT_CHARACTERISTIC followed by BT_GATT_CCC, or the Characteristic Value Declaration which is automatically created after the Characteristic Declaration when using BT_GATT_CHARACTERISTIC, or the Client Characteristic Configuration Descriptor (CCCD) which is created by BT_GATT_CCC. Return true if the attribute object has been subscribed. Parameters · conn: Connection object. · attr: Attribute object. · ccc_value: The subscription type, either notifications or indications.
OK, based on the documentation, this seems to be what I want, but the parameters are difficult for a newbie to understand: conn – yes I did declare this with BT_GATT_CHARACTERISTIC I know where it is in my source code, but how do I find a pointer to it? attr – this was automatically created with BT_GATT_CCC in the same place, but again how do I get a pointer to the attr? ccc_value – this is obviously an int, probably with definitions for the bits, but what symbolic enums or defines can I put in this parameter?
Unfortunately a google search of “bt_gatt_is_subscribed” only finds 8 results, the source code, the documentation (on the zephyr site, and on the nordic site), and 2 content aggregators. I did not find a single piece of code that calls this function, but there must be at least one call to the function in at least some test suite. bt_gatt_is_subscribed is never called in any of the zephyr/samples…
Can someone point me to an example please?
Lawrence King Principal Developer Connected Transport Market Unit +1(416)627-7302
CONFIDENTIAL: This e-mail and any attachments are confidential and intended solely for the use of the individual(s) to whom it is addressed. It can contain proprietary confidential information and be subject to legal privilege and/or subject to a non-disclosure Agreement. Unauthorized use, disclosure or copying is strictly prohibited. If you are not the/an addressee and are in possession of this e-mail, please delete the message and notify us immediately. Please consider the environment before printing this e-mail. Thank you.
|
|
bbradley@...
Hello,
I hope I am posting this question in the correct place. I have an interrupt handler which can be configured to trigger on either edge. This is working perfectly, but I want to perform a different action on a rising edge vs a falling edge in some cases. Is there any way to do this? (i.e., perhaps I can determine in the interrupt context that a rising edge and not a falling edge was triggered?) I am configuring the interrupts and registering the handler using the gpio API (gpio_pin_configure, gpio_init_callback, gpio_add_callback, gpio_pin_enable_callback), but the interrupt handler will act differently on a rising edge vs falling edge, for instance, so it is helpful to know which specific flags were raised that triggered the interrupt. I am currently using the gpio_pin_read API to work around this, but I am not sure if this is the best solution. In other MCU's there is often an API to read the status register containing the interrupt flags that have been raised, and then an API for clearing the status register after reading. Is there anything similar with Zephyr? Or perhaps there is a way to have two different handlers for rising edge/falling edge? I am using Zephyr v2.0.99 right now. Thanks for any help, Brian
|
|
I have downloaded the Arduino IDE and that includes a version of BOSSAC that may be useful. That may be a quickest method to find a working replacement version.
My interest in the use of bossac comes from the release of the Arduino Nano 33 BLE (Sense) as they are based on nRF52840 with a special boot-loader designed to work in the arduino environment. I am looking to see if it is possible to use zephyr on these boards without having to replace the boot-loader which may not be possible. I do know that the boot-loader can easily be replacement via the debug interface pins on the underside of these board but that's not that useful for most people. Billy..
|
|
@yasokada
I have checked old SDKs.
SDK v0.9.2 (20 Oct 2017): no "-o" option for bossac. SDK v0.9.1 (20 May 2017): no "-o" option for bossac. The "-o" for bossac.py is added on 9 Jul 2018 https://github.com/zephyrproject-rtos/zephyr/commit/bde3224c911176a6af4fa60a067c7492dfc76fe4 I just wonder which environment they did check. It may be possible to replace bossac binary with "-o" option, but I am not sure whether it is best way for Zephyr. I will just check further information myself, but for a while, I give up using Adafruit Trinket M0 and will use other boards.
|
|
Bolivar, Marti
Hi Yas,
"yasokada via Lists.Zephyrproject.Org" <yasokada=gmail.com@lists.zephyrproject.org> writes: Dear MartiCorrect -- where the binary in question is the one provided with the SDK. It may be unmaintained. I am not sure :).I would try compiling bossac from source trying that version. PleaseI will see. Updating the SDK somehow broke the condition to compileThis I'm not sure about either. I don't know if anybody was actively testing this with the SDK in previous versions. I just meant by this that if nobody is actively maintaining this, you may have to figure this issue out for yourself, unfortunately. Best, Marti
|
|
@yasokada
Dear Marti
Thank you very much for taking your time for this. From your information, it seems the bossac has "-o" options in source code, but does not have in binary execution code. > I would try compiling bossac from source trying that version. Please > consider filing a bug against the Zephyr SDK about the missing option if > that solves your issue. I will see. From your information again, it seems the Adafruit Trinket M0 is unmaintained. Updating the SDK somehow broke the condition to compile and flash the Trinket M0 in current SDK version. I will check how to solve this.
|
|
BBC-Microbit GPIO Mesh demo
#bluetooth
#nrf51822
#zephyrbluetoothmesh
#sensor
#ble
Daniel Fox <danny.fox97@...>
Hi im a beginner trying to work with the bbc microbits for my engineering project, my task involves using mesh networking on the bbc microbits to send a message to the user's computer stating motion is detected by a PIR motion sensor.
Im currently building off the demo as all I need is to change the button press to read the GPIO pin which the motion sensor will be hooked up to on the board. Then as the motion is detected it will act as if the button has been pressed like in the mesh demo and send a message to the other devices on the network. My current problem is that the program only reads the connection pin and switches to a 1 instead of 0, it doesn't react to motion from the sensor.It is switching between 0 and 1 while the cable is connected to the GPIO pin. Can someone please help I cannot get this to work , I have also tried the button examples and the GPIO examples on zephyr. snippets of code taken from mesh_demo #define PIR EXT_P0_GPIO_PIN
static struct device *gpio;
static struct device *nvm;
static struct device *pwm;
static struct k_work button_work;
static void button_send_pressed(struct k_work *work)
{
printk("button_send_pressed()\n");
board_button_1_pressed();
}
static void button_pressed(struct device *dev, struct gpio_callback *cb,
u32_t pins)
{
struct mb_display *disp = mb_display_get();
if (pins & BIT(SW0_GPIO_PIN)) {
k_work_submit(&button_work);
} else {
u16_t target = board_set_target();
if (target > 0x0009) {
mb_display_print(disp, MB_DISPLAY_MODE_SINGLE,
K_SECONDS(2), "A");
} else {
mb_display_print(disp, MB_DISPLAY_MODE_SINGLE,
K_SECONDS(2), "%X", (target & 0xf));
}
}
}
static void configure_button(void)
{
static struct gpio_callback button_cb;
k_work_init(&button_work, button_send_pressed);
gpio = device_get_binding(SW0_GPIO_CONTROLLER);
gpio_pin_configure(gpio, PIR ,
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
GPIO_INT_ACTIVE_HIGH|
GPIO_INT_DEBOUNCE | GPIO_PUD_PULL_UP));
gpio_pin_configure(gpio, SW1_GPIO_PIN,
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
GPIO_INT_ACTIVE_LOW));
gpio_init_callback(&button_cb, button_pressed,
BIT(PIR ) | BIT(SW1_GPIO_PIN));
gpio_add_callback(gpio, &button_cb);
gpio_pin_enable_callback(gpio, PIR );
gpio_pin_enable_callback(gpio, SW1_GPIO_PIN);
while (1) {
u32_t val=1;
int ret;
printk("toggling pin %d\n", PIR );
ret = gpio_pin_read(gpio, PIR , &val);
if (ret) {
printk("error %d\n",PIR );
}
if (val){
val=0;
}else {
val=1;
}
printk("VALUE pin %d\n", val);
k_sleep(100);
}
|
|
Bolivar, Marti
Hi Yas,
"yasokada via Lists.Zephyrproject.Org" <yasokada=gmail.com@lists.zephyrproject.org> writes: [Edited Message Follows]I checked the bossac source code and the option seems to be available, so it doesn't look like there's a problem with the bossac.py code in the zephyr repository that is using --offset: https://github.com/shumatech/BOSSA/blob/master/src/bossac.cpp#L185 I'm not sure why the bossac that ships with the Zephyr SDK doesn't have the --offset option. I checked the version that ships with bossa-cli on Ubuntu 18.04 and it doesn't seem to have it either, as you say. I would try compiling bossac from source trying that version. Please consider filing a bug against the Zephyr SDK about the missing option if that solves your issue. By the way, it looks like the person who added this board in commit 4f9864b15b263dcf7d6e204ac79f3d96a8a30e64 is no longer active on Zephyr (the last contribution they made is from March 2018), so it's possible that this board is unmaintained. Hope you figure out your issue. Thanks, Marti
|
|
amore@...
My environment : Debian 10
zephyr SDK 0.10.3 zephyr 2.1.0-rc2 I'm Interfacing Max44009 with nrf52840 on a custom make board in zephyr. I'm using the sample sensor program for MAX44009. Configured with appropriate overlay and prof.conf according to the MAX44009 datasheet . After flashing I'm getting Illegal use of ESPR on serial console. I can't seem to figure why this is happening as i'm not majorly modifying with the sample code. Please suggest debugging . Thanks in advance.
|
|
API meeting: Agenda
Carles Cufi
Hi all,
This week we will focus on GPIO: - GPIO: Update on progress - Look at the PRs with driver conversion (https://github.com/zephyrproject-rtos/zephyr/issues/18530) - Check users of GPIO APIs: https://github.com/zephyrproject-rtos/zephyr/issues/20017 - Tips for converting users can be found here: https://github.com/zephyrproject-rtos/zephyr/issues/20017#issuecomment-549315497 (thanks Peter!) - Any additional outstanding PRs to topic-gpio Additional items in the "Triage" column in the GitHub project may be discussed if time permits. If you want an item included in the meeting, please add it to the GitHub project. https://github.com/zephyrproject-rtos/zephyr/wiki/Zephyr-Committee-and-Working-Group-Meetings#zephyr-api-discussion https://github.com/zephyrproject-rtos/zephyr/projects/18 https://docs.google.com/document/d/1lv-8B5QE2m4FjBcvfqAXFIgQfW5oz6306zJ7GIZIWCk/edit Regards, Carles
|
|
Dear Marti and William
Thank you for your reply. I tried using "--bossac-port", but still have problem about "-o" option. I checked my bossac option by ``` $ ~/Zephyr_191116/zephyr-sdk-0.10.3/sysroots/x86_64-pokysdk-linux/usr/bin/bossac --help ``` ``` Usage: bossac [OPTION...] [FILE]
Basic Open Source SAM-BA Application (BOSSA) Version 1.7.0
Flash programmer for Atmel SAM devices.
... ```
There is no "-o" option for my bossac. My environment is Ubuntu 18.04 LTS. I have found this. Adafruit Trinket M0 Bossac Offset is Wrong #16052 https://github.com/zephyrproject-rtos/zephyr/issues/16052 For Adafruit Trinket M0, the address is specified using "-o 0x2000". However, because my bossac does not have "-o" option, the problem occurs. It seems that I have to update my environment to have newer? bossac version.
|
|
moreaniket219@...
ninja flash
[0/1] Flashing stm32_min_dev_blue -- west flash: using runner openocd -- runners.openocd: Flashing file: /home/amore/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.hex Open On-Chip Debugger 0.10.0+dev-00992-g3333261df-dirty (2019-08-16-00:14) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD adapter speed: 1000 kHz adapter_nsrst_delay: 100 none separate Info : clock speed 1000 kHz Info : STLINK V2J31S7 (API v2) VID:PID 0483:3748 Info : Target voltage: 3.259867 Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 100ms Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure Polling target stm32f1x.cpu failed, trying to reexamine Examination failed, GDB will be halted. Polling again in 300ms Info : Listening on port 3333 for gdb connections TargetName Type Endian TapName State -- ------------------ ---------- ------ ------------------ ------------ 0* stm32f1x.cpu hla_target little stm32f1x.cpu unknown Error: mem2array: Read @ 0xe0042004, w=4, cnt=1, failed /home/amore/zephyr-sdk-0.10.3/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts/mem_helper.tcl:6: Error: in procedure 'ocd_process_reset' in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 251 in procedure 'mmw' in procedure 'mrw' called at file "/home/amore/zephyr-sdk-0.10.3/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts/mem_helper.tcl", line 36 at file "/home/amore/zephyr-sdk-0.10.3/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts/mem_helper.tcl", line 6 Info : Previous state query failed, trying to reconnect Error: jtag status contains invalid mode value - communication failure TARGET: stm32f1x.cpu - Not halted ERROR: command exited with status 1: /home/amore/zephyr-sdk-0.10.3/sysroots/x86_64-pokysdk-linux/usr/bin/openocd -s /home/amore/zephyr-sdk-0.10.3/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts -f /home/amore/zephyrproject/zephyr/boards/arm/stm32_min_dev/support/openocd.cfg -c init -c targets -c 'reset halt' -c 'flash write_image erase /home/amore/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.hex' -c 'reset halt' -c 'verify_image /home/amore/zephyrproject/zephyr/samples/basic/blinky/build/zephyr/zephyr.hex' -c 'reset run' -c shutdown FAILED: zephyr/cmake/flash/CMakeFiles/flash cd /home/amore/zephyrproject/zephyr/samples/basic/blinky/build && /usr/local/bin/cmake -E env /home/amore/.local/bin/west flash --skip-rebuild ninja: build stopped: subcommand failed. Im trying to flash on stm32 min board using ST-Link but it keeps giving me this error. i have install openocd for the original sites but still keep getting this error. can someone point me in the right direction.
|
|
Not completely sure i understand your question but hopefully this will help.
Step 3: west flash This builds your application then flash your device. So steps to flash your application are: Step 1: Identify port Find port on Linux
This is defined at 'scripts/west_commands/runners/bossac.py' as DEFAULT_BOSSAC_PORT = '/dev/ttyACM0'. Update the port identified in Step 1 Step 3: Build and Flash Board Run West Flash If configured correctly West will build and write application to board. Billy..
|
|