This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issue with buttons_led_init when trying to program with HX711

Hello,

I am using a nRF52840-DK with an HX711 in SES. I have been utilizing the code provided by Vidar Berg that can be seen here

I downloaded the zip file, unzipped it, and then copied it into the ble_app_uart example folder, running the pca10056_s140 SES project file with the main.c, hx711.c, and hx711.h files from Vidar's code above. Everything complies correctly but I noticed the device wasn't advertising. Whenever I upload the code, LED5 begins flickering/flashing rapidly, and no other LEDs turn on. After some debugging I realized the program is prompting an error in buttons_led_init. The error is highlighted below in the main.c file.

Other people have gotten this code to work quite easily, and I trust that is correct considering Vidar wrote it. However after hours of debugging, changing memory, using DK boards, modifying files, and searching the devzone, I have found nothing that has worked. I am new to the nRF community so I feel like I may be making an obvious mistake. If anyone has any suggestions or tips, it would be much appreciated! Thanks in advance.

  • Update: It is the BSP_INIT_BUTTONS that is returning the error. Not sure how to fix this

  • Hi,

    Please elaborate on what you have found during your debugging. Specifically, which error code is returned from the call to bsp_init()? The error code will most of the time give a fairly good indication about what the problem is. I interpret what you wrote to mean that you don't get the error if you don't include BSP_INIT_BUTTONS in the call to buttons_led_init(), is that correct? If so, then the problem probably is within the "if (type & BSP_INIT_BUTTONS)" statement in the bsp_init implementation in bsp.c. You can debug to see exactly where.

  • When I compile and build I do not get any errors. However, the device is not advertising. When I debug, I always end in NRF_BREAKPOINT_COND, seen in the screenshot below.

    When I trace this back, I find out that the error check after "uint32_t err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);" is where I receive an error as seen in the screenshot from my original post. This error code only occurs when BSP_INIT_BUTTONS is present in the bsp_init() function as the code works when BSP_INIT_LEDS is the only initial argument. So, yes you are correct in your interpretation. 

    I'm not sure if the issue is within bsp.c though, as buttons_led_init() works in any program where I don't call hx711_init(). Also, I have not modified bsp.c. So I assume hx711_init() is for some reason affecting my buttons_led_init(), but I do not understand why as I have not modified either files and the zip file I downloaded the hx711 files seems to be working without issue for others.

    Thanks

  • It probably has something to do with the fact that the main.c, hx711.c, and hx711.h files were written to support s132 and I am using a s140. Do you know if this could be the case and if so how I could fix it?

  • Yes. Have you remembered to adjust the pin configuration on line 30-32 in hx711.c to match your board? There you can see that it uses pin 23, 24 and 24. That overlaps with the buttons, as button 4 uses P0.24 and button 4 uses P0.25. So you need to select other pins.

Related