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.

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

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

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

  • I adjusted them, but didn't realize button 4 used P0.25. That got rid of my initial error. Thank you. However, now I am receiving the following error:

    <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at C:\nRF52840-DK\nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_uart_SDK\main.c:566
    PC at: 0x00029081

    What should my Macro memory values be? I thought they were correct at 

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x100000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x40000

    FLASH_START=0x26000

    FLASH_SIZE=0xda000

    RAM_START=0x20002a98

    RAM_SIZE=0x3d568

    I have also tried modifying total links to 12, peripheral and central links to 6, and including the code linked here to ble_stack_init() to attempt to increase the attribute table size. Nothing has worked yet. Any ideas?

  • Hi,

    Which function returns NRF_ERROR_NO_MEM? (It seems you have made some modifications to Vidars example, so the line number (566) does not match with the code I have).

    JWCode said:
    What should my Macro memory values be? I thought they were correct at 

    Some of it depends. In short:

    • FLASH_START: should be the same as the size of the SoftDevice (you can either check in an example project using the same SoftDevice or the SoftDevice specification).
    • FLASH_SIZE: Usually not that important unless you are using a lot of flash, but strictly speaking it should be set to the total flash size - FLASH_START - any-other-flash-usage-such-as-fds.
    • RAM_START: It depends on the SoftDevice configuration. If you have changed the SoftDevice configuration (such as the number of peripheral or central links or attribute table size), this will increase. It is difficult to calculate, which is why the SoftDevice will tell you how to adjust it. See Adjustment of RAM and Flash memory for details.
    • RAM_SIZE: Physical RAM size - RAM_START.
    • The other parameters (*_PH_*) are supposed to represent the physical memory of the device, but it is not used for anything so it can be ignored.
    JWCode said:
    I have also tried modifying total links to 12, peripheral and central links to 6, and including the code linked here to ble_stack_init() to attempt to increase the attribute table size. Nothing has worked yet. Any ideas?

    Why did you adjust the link counts? Using multiple links is no problem, but it is a good idea to get one thing working before moving on to the next.

Related