cancel
Showing results for 
Search instead for 
Did you mean: 

Problem driving PORT C1 High - suspect bad chip or device configuration error.

SKill
Associate II

 I have a legacy design with a STM8L052C6 MCU. There is a 4x3 matrix keypad. I am trying to drive the Rows and scan the columns. The C1 port only rises to about 0.5V when I set the pin HIGH. Is there something I am missing.

There are three ports set as PP_HIGH_FAST outputs (Ports A3 and E7 work as expected. Port C1 exhibits the 0.5V high. VDD is 3V. There is a 510K resistor pull up on this pin in the design that is not on the other pins. I am recreating the source code for the board and am not sure why the resistor is there or why I can't get C1 to go full high. I have tried OD as well as the SLOW options. BTW what is the difference between the LOW and HIGH options in the peripheral driver GPIO_Mode_TypeDef options.

// Matrix Keypad Scanner Drivers

#define KP_ROW1_PORT               GPIOA

#define KP_ROW1_PIN                  GPIO_Pin_3

#define KP_ROW2_PORT               GPIOE

#define KP_ROW2_PIN                  GPIO_Pin_7

#define KP_ROW3_PORT               GPIOC

#define KP_ROW3_PIN                  GPIO_Pin_1

// Matrix Keypad Scanner Receivers

#define KP_COL1_PORT               GPIOC

#define KP_COL1_PIN                  GPIO_Pin_4

#define KP_COL2_PORT               GPIOC

#define KP_COL2_PIN                  GPIO_Pin_7

#define KP_COL3_PORT               GPIOE

#define KP_COL3_PIN                  GPIO_Pin_6

#define KP_COL4_PORT               GPIOA

#define KP_COL4_PIN                  GPIO_Pin_2

   /* Initialize Keypad Pins */

   // Driver Pins

   GPIO_Init(KP_ROW1_PORT, KP_ROW1_PIN, GPIO_Mode_Out_PP_High_Fast);

   GPIO_Init(KP_ROW2_PORT, KP_ROW2_PIN, GPIO_Mode_Out_PP_High_Fast);

   GPIO_Init(KP_ROW3_PORT, KP_ROW3_PIN, GPIO_Mode_Out_PP_High_Fast);

//   GPIO_ExternalPullUpConfig(KP_ROW3_PORT, KP_ROW3_PIN, ENABLE);

   // Receiver Pins

   GPIO_Init(KP_COL1_PORT, KP_COL1_PIN, GPIO_Mode_In_FL_No_IT);

   GPIO_Init(KP_COL2_PORT, KP_COL2_PIN, GPIO_Mode_In_FL_No_IT);

   GPIO_Init(KP_COL3_PORT, KP_COL3_PIN, GPIO_Mode_In_FL_No_IT);

   GPIO_Init(KP_COL4_PORT, KP_COL4_PIN, GPIO_Mode_In_FL_No_IT);

// ==============

Here is the test code I am using to create the key scanner for the three ports.

// ==============

      GPIO_SetBits(KP_ROW1_PORT, KP_ROW1_PIN);

      for(i=0x1FF; i>0; i--);

      GPIO_ResetBits(KP_ROW1_PORT, KP_ROW1_PIN);

      for(i=0x1FF; i>0; i--);

      GPIO_SetBits(KP_ROW2_PORT, KP_ROW2_PIN);

      for(i=0x1FF; i>0; i--);

      GPIO_ResetBits(KP_ROW2_PORT, KP_ROW2_PIN);

      for(i=0x1FF; i>0; i--);

      GPIO_SetBits(KP_ROW3_PORT, KP_ROW3_PIN);

      for(i=0x1FF; i>0; i--);

      GPIO_ResetBits(KP_ROW3_PORT, KP_ROW3_PIN);

      for(i=0x1FF; i>0; i--);

1 REPLY 1
SKill
Associate II

Turns out that the issue was not the code nor the MCU; the issue was that the scope digital pod I was using presented a 100K load on the MCU pins and that was enough to overload the drive capability and cause the pin's reduce signal and stop the receiving port from detecting the pressed key on the keypad.