Only getting encoder events in one direction

Hi all,

I’m at the beginning of writing a C application on MIOS8. The hardware is composed of a Core '452, a DIN and two voti.nl encoders attached to it (http://www.voti.nl/shop/catalog.html?SW-ROT-01). I’m using input pins 0/1 and 2/3.

I’m using the skeleton application as a starting point (sdcc_skeleton_v1_1). MIOS on the chip is upgraded to version 1.9h.

If I don’t configure any encoders, I can see button events coming through DIN_NotifyToggle:

[16083.144] Button: 00 pressed
[16083.153] Button: 01 pressed
[16083.162] Button: 00 depressed
[16083.171] Button: 01 depressed
[16083.239] Button: 00 pressed
[16083.248] Button: 01 pressed

… and so on. But if I add an encoder table for a single encoder, like

#include <cmios.h>
#include <pic18fregs.h>
#include <debug_msg.h>

MIOS_ENC_TABLE {
  MIOS_ENC_ENTRY(1, 0, MIOS_ENC_MODE_DETENTED2),
  MIOS_ENC_EOT 
};

, I receive encoder events only for clockwise rotations (negative increments).

If i change the encoder type to DETENTED/3/4/5, i get no events at all.

Same exact thing happens with the other encoder, and even if I enable both (MIOS_ENC_ENTRY(1, 2, MIOS_ENC_MODE_DETENTED2)).

I don’t think there’s a hardware problem because it seems to me that the input pins are working fine. Also, using different pins or using a second DIN didn’t help.

What did go wrong?..

 

Thanks!

Best regards,

Enrico

 

Just found the issue. After a read of http://www.midibox.org/dokuwiki/doku.php?id=encoders, I found out that the two rightmost pins of the encoders were swapped