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.

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

  • The same function I mentioned earlier(buttons_leds_init) returns the no memory error. It seems the adjustment of pins just changed the error code from error 8 to error 4. Specifically, the following two lines:

    uint32_t err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
    APP_ERROR_CHECK(err_code);

    Thanks for the thorough description of the Macros, that clears it up. I have changed the link counts back, I had just seen it suggested as a possible solution for the error code I have been receiving, but am still receiving the NO_MEM error.

Reply
  • The same function I mentioned earlier(buttons_leds_init) returns the no memory error. It seems the adjustment of pins just changed the error code from error 8 to error 4. Specifically, the following two lines:

    uint32_t err_code = bsp_init(BSP_INIT_LEDS | BSP_INIT_BUTTONS, bsp_event_handler);
    APP_ERROR_CHECK(err_code);

    Thanks for the thorough description of the Macros, that clears it up. I have changed the link counts back, I had just seen it suggested as a possible solution for the error code I have been receiving, but am still receiving the NO_MEM error.

Children
Related