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

I am looking for simple example of HW driver of QDEC for nrf5340.

Hi.
I am looking for simple example of using QDEC for nrf5340.
I want to use the Segger Embedded Studio.


Where can I find the example of some guide for HW driver for nrf5340pdk?
When I compile the project “blinky_pwm” I get the error “Unsupported board: pwm-led0 devicetree alias is not defined”. How can I define the correspond HW?

Parents Reply Children
  • Hi Sigurd, could you explain how to use this using the callback handler?

    I have it set up for the NRF52840 using CONFIG_QDEC_NRFX (and CONFIG_SENSOR although I guess I rather use it wihout).

    The pins etc are all setup in an overlay file.

    &qdec {
        status = "okay";
        a-pin = <42>;
        b-pin = <43>;
        enable-pin = <30>;
        led-pin = <0xFFFFFFFF>;
        led-pre = <0>;
        steps = <12>;
    };

    When I call this:

     

           int ret = nrfx_qdec_init(conf, rotaryHandler);

    The rotaryHandler is never called, what am I missing?

    I have added a simple read function in a while loop that actually works, but not in the way I want. at least it tells me the hardware setup seems ok.

          void readRotary(){
              int *acc;
              int *accd;
              nrfx_qdec_accumulators_read(&acc, &accd);
              if (acc != prevacc)  printf("acc: %d, Acc double: %d\n", acc, accd);
              prevacc = acc;
              prevaccd = accd;
          }

    running that code show this:

    turning one side: 

    acc: 0, Acc double: 0
    acc: 1, Acc double: 0
    acc: 0, Acc double: 0
    acc: 1, Acc double: 0

    other side:

    acc: 65535, Acc double: 0
    acc: 0, Acc double: 0
    acc: 65535, Acc double: 0

  • Hi Steven,

    It could be that you forgot nrfx_qdec_enable(). If that does not solve the issue, then please create a new post for your question: https://devzone.nordicsemi.com/support/add

  • Hi.

    Can you create a simple sample for QDEC using?
    I read the data from encoder and it always zeros. And all HW registers of qdec also are zeros.

Related