Experiment#9: Question#1
Experiment#9: Question#1
Question#1
Code:
LCD_init ();
LCD_string ("String is Displayed");
}
}
while (1) {
GPIOC_BSRR = 0x0000000F; //Set all Columns
while ((GPIOC_IDR & 0xF0) == 0); //wait till any key is pressed
keypad ();
while ((GPIOC_IDR & 0xF0) != 0); //debouncing
}
}
int val = 0;
void main(void) {
RCC_APB2ENR = 0x18; //enable Port B & C
RCC_APB1ENR = 0x1; //enable Timer2
GPIOC_CRL &= 0x88882222; //rows as input and columns as output
GPIOC_CRL |= 0x88882222; //rows as input and columns as output
GPIOB_CRL &= 0x22222222; //LEDs connected from PB0-PB7
GPIOB_CRL |= 0x22222222;
while (1) {
GPIOC_BSRR = 0x0000000F; //Set all Columns
while ((GPIOC_IDR & 0xF0) == 0); //wait till any key is pressed
keypad ();
while ((GPIOC_IDR & 0xF0) != 0); //debouncing
}
}
int val = 0;
void main(void) {
RCC_APB2ENR = 0x18; //enable Port B & C
RCC_APB1ENR = 0X1; //enable Timer2
GPIOC_CRL &= 0X88882222; //rows as input and columns as output
GPIOC_CRL |= 0X88882222; //rows as input and columns as output
GPIOB_CRL &= 0XF2222222; //PB0-PB3 as LCD data pins
GPIOB_CRL |= 0X02222222; // R/W on PB4, E on PB5, RS on PB6
GPIOB_BSRR = 0X00000010; //R/W on PB4 as continuous Low
LCD_init ();
LCD_string ("L1F18BSEE");
while (1) {
GPIOC_BSRR = 0x0000000F; //Set all Columns
while ((GPIOC_IDR & 0xF0) == 0); //wait till any key is pressed
keypad ();
while ((GPIOC_IDR & 0xF0) != 0); //debouncing
}
}
Conclusion:
From this experiment it is learnt that how to interface a Keypad with STM32 board. It is also
learnt that how to design a logic for controlling the input from the Keypad and displaying it on an
LCD. A keypad consists of switches on each button that let the current pass through them and complete
the circuit. It is learnt that there are two ways to configure the keypad, one is to set all rows and take
output from columns, other way is to set all columns and take output from rows. It is also learnt that
the numbers written on the keypad are not given as output to the controller, in fact the output can be
programmed to by the programmer in any way, the program written will decide what to do with the
input from keypad. Different logics are implemented on keypad’s output and different functions are
performed in this experiment. Keypad is no different than a push button, we can consider it as a matrix
of push buttons, of which the output can be programmed in any way, according to our requirements.
The interconnected operation of keypad with LCD is also studied and understood.