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

Timer Issue With HX711 - Stopped By Vector Catch Error

Details: SDK v15.2.0 using HX711 sample code copy-pasted over twi_master_using_nrf_twi_mngr example. Windows 8.1, uploading to nRF52 DK.

I am having a hard time understanding this section of code. I read the timer section in the product specs v1.4, but I am clearly still not understanding it fully.

  • When I run it in the debugger, it loops through the do-while loop in the section of code below a lot and never increments any timer1 or timer2 register values. I added the NRF_LOG_INFO((int) NRF_TIMER2->CC[1]); line to try and readout the value but it just sends LOG: "blank"
  • When I build and run it on the board, it tells me "stopped by vector catch"

When I read the code above, it tells me this:

  • loop through until i equals the number of ADC bits desired
  • capture timer2 value to CC[1] register
  • if: CC[1] (set to timer2 value) is equal or greater than ADC bits then exit (but timer2 was never started, why??)
  • else: logger
  • continue to do this until timer1 events_compare[0] is not zero (but CC[0] was initialised to 1, and events_compare would only go high if timer1 was equal to the value in CC[0] so unless timer1 overflows, it's unlikely it will catch??)
  • reset events_compare[0]

This code was written by Vidar so I'm sure it works fine. I feel like I'm doing something wrong

My main function looks like this:

Parents
  • Hi, 

    I am having a hard time understanding this section of code

    That's understandable, I would have had a hard time understanding it as well had I not written it myself. Here are a couple of hints that may help clarify what I did:

    - TIMER1 + PPI + GPIOTE generates the clock signal (PD_SCK)

    - TIMER2 is set up as counter is and incremented on the falling edge of each PD_SCK clock cycle (TIMER1 CC[1] event is connected to timer 2 task through PPI). 

    Anyway, it's usually easier to start with an example so I've integrated the driver into to our ble_app_uart example, see attached. Just extract the zip file and copy the folder to /nRF5_SDK_15.2.0_9412b96/examples/ble_peripheral, then open the project in Segger Embedded studio. Pinout is defined in hx711.c. Please let me know whether it works or not. 

     ble_app_uart_w_hx711.zip

  • Works. Thank you. The only issue I have is that when I connect through Nordic Connect and read the TX Characteristic the values show up as black question marks. Something to do with my LG Q6 not reading the character codes correctly...

  • Thanks for confirming. I didn't have the ADC to test with. Regarding the black question marks, you can use sprintf, etc to encode the data. 

  • Did you simply extract the zip file and run it? I am unable to get anything other than 0's in my TX characteristic values. Help would be much appreciated

Reply
  • Did you simply extract the zip file and run it? I am unable to get anything other than 0's in my TX characteristic values. Help would be much appreciated

Children
No Data