Core32F4 J5a Encoder

10 posts in this topic

i want to connect one Encoder directly to J5a

i know that in my Code i have to

initalize this pins:

  // initialize pin 2 of J5A,  as Digital input with internal Pull-UP //connect to ground

and i also can observe the state of the J5a pin by putting following code into APP_Background:


all clear so far, and working good with buttons (with hardware debouncing ):



how does a Encoder-Code look like (without any Acceleration), and how does Hardware debouncing look like (the same like for buttons?), i want to use as less code then possible...


thx 4 any tips


Share this post

Link to post
Share on other sites


Leveraging the topic.
I use the LCP1769
I'm testing the example "014b_enc_j5_relative".
It only works J5A (A0 ... A3) and J5B (A4 ... A7) does not work.

This example tests all inputs A0 ..... A7 on the J5A and J5B connector? How do I set up so that all inputs A0 .... A7?

I tested J5A / B as analog inputs and they all worked. I just set "#define MIOS32_AIN_CHANNEL_MASK 0x00ff"

Share this post

Link to post
Share on other sites

This Settings in "mios32_config.h" are working for 0-7A (5a,5b) - i am on a stm32f4

#define MIOS32_AIN_CHANNEL_MASK 0x00ff
// AIN define the deadband (min. difference to report a change to the application hook)
#define MIOS32_AIN_DEADBAND 31 //7Bit


Edited by Phatline

Share this post

Link to post
Share on other sites

Hi !!


Strange, would not that just be for analog inputs? A0 .... A3 work fine without setting "#define MIOS32_AIN_CHANNEL_MASK 0x00ff".
I do not want analog inputs. I want 4 encoders


Tks Marco.

Share this post

Link to post
Share on other sites

ahhh sorry, may fault...

what i have done with J10A-B (if you replace J10 with J5 i think its the same)

@top of programm (declaration)

// ENCODER            SR begin with 1, ENC with 0)   //    setup the Pinout of Encoders
    const mios32_enc_config_t encoders[1] = {{ .cfg.type=DETENTED2, .cfg.speed=FAST, .cfg.speed_par=3,, .cfg.pos=0 }};


void APP_Init(void){
  BLM_SCALAR_Init(0);   // initialize BLM_SCALAR driver

// Set GPIO @ J10A+B
  int pin;
  for(pin=0; pin<16; ++pin){
// Set Menue Encoder
  int enc;
  for(enc=0; enc<4; ++enc) {
    mios32_enc_config_t enc_config = MIOS32_ENC_ConfigGet(enc);
    enc_config.cfg.type = DETENTED3; // see mios32_enc.h for available types = 0; // must be 0 if controlled from application
    enc_config.cfg.pos = 0; // doesn't matter if controlled from application
    enc_config.cfg.speed = FAST;
    enc_config.cfg.speed_par = 0;
    MIOS32_ENC_ConfigSet(enc, enc_config);}


void APP_SRIO_ServicePrepare(void)  {
  // get current J10B value and update all encoder states
    int enc;
    u16 state = MIOS32_BOARD_J10B_Get();
    for(enc=0; enc<4; ++enc) {
    MIOS32_ENC_StateSet(enc, state & 3); // two pins
    state >>= 2; // shift to next two pins


Share this post

Link to post
Share on other sites

Just got a flashback: this is actually a known issue and I thought that I fixed this some years ago... somehow the change didn't find it's way into the repository.

I updated mios32/LPC17xx/mios32_board.c, please update your repository

Best Regards, Thorsten.

Share this post

Link to post
Share on other sites
1 hour ago, TK. said:

Acabei de receber um flashback: este é realmente um problema conhecido e achei que consertei isso há alguns anos ... de alguma forma, a mudança não encontrou o caminho para o repositório.

Eu atualizei o mios32 / LPC17xx / mios32_board.c, atualize seu repositório

Atenciosamente, Thorsten.

Hi TK,

Thank you so much!!! Now it works !!!! I've been looking for where the bug would be for two days and today I would look at "mios32_board.c". Thanks for the quick help !!!


Edited by kmargos

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now