Showing results for 
Search instead for 
Did you mean: 

unable to read port memory

Associate III

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

       uint16_t mask = 0x0FFF;

       KeyInputMemory[column_count] &= mask;


    if (KeyInputMemory[column_count] == StoredKeyInput[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;




    } 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

ST Employee

Hello @Girish1 


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


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


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.

If you feel a post has answered your question, please click "Accept as Solution".