Please show me Code to implement this on the STM32 #include "stm32f0xx.h" #include "lcd_stm32f0.c" #include #include //========================================================================== // GLOBAL CONSTANTS #define SW0 GPIO_IDR_B #define SW1 GPIO_IDR_1 #define SW2 GPIO_IDR_2 #tdefine SW3 GPIO_IDR_3 //========================================================================= // GLOBAL VARIABLES unsigned int bitpattern = 0b@0@0110011111111; //=========================================================================== // FLNCTION DECLARATIONS void displayStudentNumber(void); void init_LED(); void init_Button(); void check(void); void init_NVIC(void); void init_TIN14(void); void TIM14_IRQHandler(void); // MAIN FUNCTION //=?============================================= int main (void) { displayStudentNumber(); init_LED(); init_Button(); init_TIM14(); while (1){ check(); } ``` // FLMCTION DEFINLTIONS ``` ``` void displayStudentNumber(void){ init_LCD(); lcd_command(CLEAR); lcd_putstring("BQWXOLe?1"); } void init_LED(){ // Intializing GPIO for pins PBe ,PB1 ,PB6 ,PB7 RCC -> AHBENR |= RCC_AHBENR_GPIOBEN; // Enable clock for GPIOB GPIOB -> MODER |= GPIO_MODER_MODERB_0; // Configure PBO output mode. GPIOB -> MODER |= GPIO_MODER_MODER1_0; // Configure PB1 output mode. GPIOB -> MODER |= GPIO_MODER_MODER6_0; // Configure PB6 output mode. GPIOB -> NODER |= GPIO_MODER_MODER7_0; // Configure PB7 output mode. GPIOB -> ODR = bitpattern; // Configure LED DQ,D1,D6,D7 for CDR. } void init_Button(): // Enable clock for push buttons. RCC -> AHBENR |= RCC_AHBENR_GPIOAEN; GPIOA -> NODER &= ~GPIO_MODER_MODERO; GPIOA -> MODER &= ~GPIO_MODER_MCDER1; GPIOA -> MODER &= ~GPIO_MODER_MCDER2; GPIOA -> MODER &= ~GPIO_MODER_MCDER3; GPIOA->PUPDR |= GPIO_PUPOR_PUPORQ_8; GPIOA->PUPDR |= GPIO_PUPOR_PUPOR1_8; GPIOA->PUPDR |= GPIO_PUPOR_PUPOR2_8; GPIOA->PUPDR |= GPIO_PUPDR_PUPOR3_8; # // Code to intialise Timer 14 to create an event every is void init_TIN14(void){ // Enabling the TIM14 clock source. RCC -> APB1ENR |= RCC_APB1ENR_TIM14EN; // enable clock // Set parameters for ARR and PRESCALER TMM14 -> PSC = 734; //if CLK = 950KHz, then Tov = 15. TIM14 -> ARR = 65306; //if CLK = 95ekHz, then Tov = 15. // Enabling the TIM14 update event interrupt (UIE) TIM14 -> DIER |= TIM_DIER_UIE; // enable Timer 14 interrupt // Start TIM14 // Set the CEN (bite) in TIM14 control register (CR1) ``` TMM14??CR1??TIM?CR1?CEN???start counter for Timer 14. \} void init?NVIC?void?\? ??Unmasking Interrupt in the Nested Vector Interrupt Controller NVIC?EnableIRQ?TIN14?IRQn????unmask the TIM14 interrupt in the NVIC \} void check?void?\? if??GPIOA??IDR \?SWO?\( ==0 \) ?\( \{ \) lcd?command?CLEAR?? GPIOB??NODER??GPIO?MOOER?MOOER3?8???Configuring LED PB3? GPIOB??NODER??GPIO?MOOER?MOOER4?8???Configuring LED PE4? GPIOB??ODR?©x?bboba18? init?NIC??? while?1? ??GPIOB \( ->0 \mathrm{ODR}= \) exeb?b?g18???Configure LED 03?04 for C0R? ??GPIOB?3NOOER??GPIO?MCOER?MCOER3?????COnfiguring LED PB3? ??GPIOB??NOOER??GPIO?MCOER?MCOER4?e???Configuring LED PB4? ??init?NVIC??? ??TIM14?IRQHandler??? ??GPIOB \( -> \) ODR \( = \) exbeb?be9?? GPIOB??MODER??GPIO?MODER?MODER2?0???Configuring LED PB2? GPIOB??MODER??GPIO?MODER?MODER5?0???Configuring LED PB5? GPIOB \( ->\mathrm{COR}= \) Exebebeg24???Configure LED D5?D2 for ODR? 1 \} \( / / \) if??GPIOA??IDR \?SW1?\( ==0)\{ \) ??GPIOB??NODER??GPIO?MCOER?MCOER2?8???COnfiguring LED PB2? ??GPIOB??NODER??GPIO?MCOER?MCOER5?0???Configuring LED PB5? ??GPIOB \( -> \) ODR?ex?g???e24???Configure LED D5?D2 for COR? ??\} \( / / \) if??GPIOA \( -> \) IDR \?SW1?\( ==0)\{ \) \( / / \) GPIOB??MODER??GPIO?MCOER?MCOER1?????COnfiguring LED PB1? ??GPIOB?3NODER??GPIO?MCDER?MOOER6?8???COnfiguring LED P86? ??\} \( / / \) if??GPIOA \( -> \) IDR \?SW1?\( ==0)\{ \) ??GPIOB??NODER??GPIO?MCOER?MOOERQ?8???COnfiguring LED PBg? \( / / \) GPIOB??MODER??GPIO?MODER?MCOER7?????COnfiguring LED PB7? \( / / \quad \) GPIOB \( -> \) ODR \( = \) ex90????81?\( / / \) Configure LED D??07 for COR? \( / / \) \} \} ``` // Interrupt handler void TIM14_IROHandler(void) { // Clearing the TIN14 update interrupt flag in the ISR. TIM14 -> SR &= *TIM_SR_UIF; // clears the interrupt flag } //*************************************************************************** // END OF PROGRAM //*************************************************************************** ```




