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

QDEC SAMPLEPER and REPORTPER relationship

Does anyone have additional information on the relationship between SAMPLEPER and REPORTPER in the nRF QDEC?

I understand that the SAMPLEPER sets the base sample period such that the QDEC will sample the inputs every SAMPLEPER time. Will this also generate the SAMPLERDY event every sample period, or only if there was a change in the inputs?

I see the REPORTPER register is used to set the number of samples to be accumulated before the REPORTRDY event is generated. However, the REPORTRDY event is only generated if the accumulator value is not 0. My question is, if the accumulator is 0 after REPORTPER samples, does the sample count get reset such that another REPORTPER samples must be taken before REPORTRDY gets generated? Or will the next sample that changes the accumulator trigger the REPORTRDY event?

For example, assume we're using REPORTPER = 10 samples/report and starting with a cleared accumulator (ACC = 0). After 10 samples, no motion has been detected, the accumulator is still 0, so the REPORTRDY event is not generated. Now assume sample 12 detects "forward" motion and increments the accumulator (ACC = 1). Is the REPORTRDY event generated immediately after sample 12, or does the REPORTRDY event not get generated until sample 20?

Thanks in advance for everyone's help with these questions.

Parents
  • Hi,

    First of all, I am very sorry for the late answer. I had some time to look at the QDEC, and tried to answer your questions. If there is anything that I have misunderstood or gotten wrong, please correct me :)

    I understand that the SAMPLEPER sets the base sample period such that the QDEC will sample the inputs every SAMPLEPER time. Will this also generate the SAMPLERDY event every sample period, or only if there was a change in the inputs?

    “SAMPLERDY” will fire every time there is a new sample, even if there is no change. Meaning, you will get this event every “value of NRF_QDEC->SAMPLEPER”. I verified this by toggling a GPIO in the event. In my case, it toggled every 128us (SAMPLEPER value I set).

    I see the REPORTPER register is used to set the number of samples to be accumulated before the REPORTRDY event is generated. However, the REPORTRDY event is only generated if the accumulator value is not 0. My question is, if the accumulator is 0 after REPORTPER samples, does the sample count get reset such that another REPORTPER samples must be taken before REPORTRDY gets generated? Or will the next sample that changes the accumulator trigger the REPORTRDY event?

    The REPORTPER is, as you say, used to set the number of samples. A period is then REPORTPER * SAMPLEPER. The event REPORTRDY is generated if accumulator value has changed since last REPORTPER*SAMPLEPER. If you do not clear the accumulator (NRF_QDEC->TASKS_READCLRACC), you can get into conditions where this will then report 0 (as the last value of acc != 0).

    For example, assume we're using REPORTPER = 10 samples/report and starting with a cleared accumulator (ACC = 0). After 10 samples, no motion has been detected, the accumulator is still 0, so the REPORTRDY event is not generated. Now assume sample 12 detects "forward" motion and increments the accumulator (ACC = 1). Is the REPORTRDY event generated immediately after sample 12, or does the REPORTRDY event not get generated until sample 20?

    I checked this with an oscilloscope, and it will only generate event after 10*SAMPLEPER in your case.

    Best regards Håkon

Reply
  • Hi,

    First of all, I am very sorry for the late answer. I had some time to look at the QDEC, and tried to answer your questions. If there is anything that I have misunderstood or gotten wrong, please correct me :)

    I understand that the SAMPLEPER sets the base sample period such that the QDEC will sample the inputs every SAMPLEPER time. Will this also generate the SAMPLERDY event every sample period, or only if there was a change in the inputs?

    “SAMPLERDY” will fire every time there is a new sample, even if there is no change. Meaning, you will get this event every “value of NRF_QDEC->SAMPLEPER”. I verified this by toggling a GPIO in the event. In my case, it toggled every 128us (SAMPLEPER value I set).

    I see the REPORTPER register is used to set the number of samples to be accumulated before the REPORTRDY event is generated. However, the REPORTRDY event is only generated if the accumulator value is not 0. My question is, if the accumulator is 0 after REPORTPER samples, does the sample count get reset such that another REPORTPER samples must be taken before REPORTRDY gets generated? Or will the next sample that changes the accumulator trigger the REPORTRDY event?

    The REPORTPER is, as you say, used to set the number of samples. A period is then REPORTPER * SAMPLEPER. The event REPORTRDY is generated if accumulator value has changed since last REPORTPER*SAMPLEPER. If you do not clear the accumulator (NRF_QDEC->TASKS_READCLRACC), you can get into conditions where this will then report 0 (as the last value of acc != 0).

    For example, assume we're using REPORTPER = 10 samples/report and starting with a cleared accumulator (ACC = 0). After 10 samples, no motion has been detected, the accumulator is still 0, so the REPORTRDY event is not generated. Now assume sample 12 detects "forward" motion and increments the accumulator (ACC = 1). Is the REPORTRDY event generated immediately after sample 12, or does the REPORTRDY event not get generated until sample 20?

    I checked this with an oscilloscope, and it will only generate event after 10*SAMPLEPER in your case.

    Best regards Håkon

Children
Related