Skip to main content
Explorer
October 16, 2023
Question

unable to read port memory

  • October 16, 2023
  • 2 replies
  • 1343 views

  KeyInputMemory[column_count] = (uint16_t)(GPIOB->IDR);

       uint16_t mask = 0x0FFF;

       KeyInputMemory[column_count] &= mask;

 

    if (KeyInputMemory[column_count] == StoredKeyInput[column_count]) {  //

 

        KeyInputCounter[column_count]++;

        if (KeyInputCounter[column_count] > 5) {

        

            StoredKeyInput[column_count] = KeyInputMemory[column_count];

 

            // Reset the counter

          //KeyInputCounter[column_count] = 0;

        }

 

    } else {

        // Store the current key input into the column stored key input

        StoredKeyInput[column_count] = KeyInputMemory[column_count];

 

        // Clear the key input count

        KeyInputCounter[column_count] = 0;

 

        //EXIT

        return;

    } I have physical keyboard i have to read b port but not detecting is my logic is true or false....... whenever key is pressed not reading the values

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    October 16, 2023

    Hello @Girish1 

     

    Would you provide more details about the issue? If possible, add more context about your Hardware setup, attach your IOC file/configuration.

     

    Super User
    October 16, 2023

    The code doesn't make a whole lot of sense here. You're comparing 12 different bits in the code. I suspect you want to look at a single bit instead.

    Suggest using HAL_GPIO_ReadPin instead if you're not comfortable with bitwise manipulation.