Here is what is asked of me The matrix keypad is 3x4 The goa
Here is what is asked of me (The matrix keypad is 3x4):
The goal of the project is to design a digital safe interface using the Nucleo ARM Cortex-M7 board. The interface shall have the following capabilities:
1) Capability to select numbers (0-9) from a matrix keypad (provided) and input them as a six-digit code into the microcontroller.
2) Capability to display entered keypad characters on the terminal I/O screen as they are entered using the keypad.
3) Capability to use the (*) character on the keypad as a “robust” delete key.
4) Capability to use the (#) character on the keypad as the enter key.
5) Use of the on-board pushbutton to enter into either “set combination” mode (2 pushbutton presses within one second) or “digital safe” mode (1 pushbutton press within one second). In “set combination” mode, one can enter a code which will be set to the new combination. In “digital safe” mode, entered combinations will be checked against the stored code. If no code is stored, the terminal should display – “CODE NOT SET”.
6) Entry into “set combination” mode or “digital safe” mode should be indicated by writing “SET COMBINATION” or “DIGITAL SAFE” to the terminal.
7) If the entered code is not six characters long, the terminal should display “ERROR”, erase the displayed code and place the cursor on the first column.
8) If the entered code has any repeated numbers (2 or more in a row), the terminal should display “BAD CODE ENTERED”, erase the displayed code and place the cursor on the first column.
9) Hitting the board reset button or restarting the program execution should erase the terminal screen, clear any stored code and default to “set combination” mode.
Here is the code i have so far, I AM GETTING NOWHERE!!
#include <stm32f7xx_hal.h>
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
void myprint (uint8_t a, uint8_t b)
{
if (a==1 && b==1)
printf(\"1\");
else printf (\"2\"); //a test to see if this would work
}
int main(void)
{
SCB_EnableICache();
SCB_EnableDCache();
HAL_Init();
GPIO_InitTypeDef A;
RCC_OscInitTypeDef B;
RCC_ClkInitTypeDef C;
B.OscillatorType = RCC_OSCILLATORTYPE_HSE;
B.HSEState = RCC_HSE_BYPASS;
B.PLL.PLLState = RCC_PLL_ON;
B.PLL.PLLSource = RCC_PLLSOURCE_HSE;
B.PLL.PLLM = 8;
B.PLL.PLLN = 432;
B.PLL.PLLP = RCC_PLLP_DIV2;
B.PLL.PLLQ = 7;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
C.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
C.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
C.AHBCLKDivider = RCC_SYSCLK_DIV1;
C.APB1CLKDivider = RCC_HCLK_DIV4;
C.APB2CLKDivider = RCC_HCLK_DIV2;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7);
A.Mode = GPIO_MODE_INPUT;
A.Pull = GPIO_PULLDOWN;
A.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
A.Pin = GPIO_PIN_13;
HAL_GPIO_Init(GPIOE, &A);
A.Pin = GPIO_PIN_15;
HAL_GPIO_Init(GPIOF, &A);
A.Pin = GPIO_PIN_14|GPIO_PIN_9;
HAL_GPIO_Init(GPIOG, &A);
A.Mode = GPIO_MODE_OUTPUT_OD;
A.Pull = GPIO_PULLUP;
A.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
A.Pin = GPIO_PIN_9|GPIO_PIN_11;
HAL_GPIO_Init(GPIOE, &A);
A.Pin = GPIO_PIN_14;
HAL_GPIO_Init(GPIOF, &A);
int row_index ;
int column_index;
int n=0;
//char code [8];
// keypad search
// pulse rows and check columns
while (n==1)
{
for (row_index=1; row_index<5; row_index++)
{
for (column_index=1; column_index<4; column_index++)
{
switch(row_index)
{
case 4: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_13, GPIO_PIN_SET); break;
case 3: HAL_GPIO_WritePin(GPIOF, GPIO_PIN_15, GPIO_PIN_SET); break;
case 2: HAL_GPIO_WritePin(GPIOG, GPIO_PIN_14, GPIO_PIN_SET); break;
case 1: HAL_GPIO_WritePin(GPIOG, GPIO_PIN_9, GPIO_PIN_SET); break;
}
switch(column_index)
{
case 3: if (HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_9)) {myprint(row_index,column_index); HAL_Delay(300);} break;
case 2: if (HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_11)) {myprint(row_index,column_index); HAL_Delay(300);} break;
case 1: if (HAL_GPIO_ReadPin(GPIOF, GPIO_PIN_14)) {myprint(row_index,column_index); HAL_Delay(300);} break;
}
//if (HAL_GPIO_ReadPin(column_port(column_index), column(colum_index))) myprint(row_index,column_index);
switch(row_index)
{
case 4: HAL_GPIO_WritePin(GPIOE, GPIO_PIN_13, GPIO_PIN_RESET); break;
case 3: HAL_GPIO_WritePin(GPIOF, GPIO_PIN_15, GPIO_PIN_RESET); break;
case 2: HAL_GPIO_WritePin(GPIOG, GPIO_PIN_14, GPIO_PIN_RESET); break;
case 1: HAL_GPIO_WritePin(GPIOG, GPIO_PIN_9, GPIO_PIN_RESET); break;
}
}
}
}
}
Solution
When you press OK on the dialog box. Python will attempt to highlight the offending line in your source code. You should use this location as a hint for where to start looking for your problem. First check the area highlighted. Then check the entire line. Lastly, check the line or lines before the line highlighted. The location marked is where Python noticed there was a problem, so the actual problem could come before! If you get an indention error, you should check that all of your lines of code are properly aligned in the correct columns. You can place you cursor at the start of each line and look at the col:indicator at the bottom right of IDLE to check this.

