Question: Modify the following source code to Click button S1 to double the LED blinking frequency Click button S2 to decrease the LED blinking frequency in

Modify the following source code to
Click button S1 to double the LED blinking frequency
Click button S2 to decrease the LED blinking frequency in half
Define a minimum (2^-4 Hz) and a maximum (2^4 Hz) blinking frequencies.  Modify the following source code to Click button S1 to double
the LED blinking frequency Click button S2 to decrease the LED blinking
frequency in half Define a minimum (2^-4 Hz) and a maximum (2^4
Hz) blinking frequencies. #include #include #include #include #define DCO_FREQ 48e6 #define TIMERO_FREQ
1 #define SYSTICK_FREQ 200 #define RED_LED GPIO_PINO #define GREEN_LED GPIO_PIN1 #define BLUE_LED
GPIO_PIN2 #define BUTTON_S1 GPIO_PIN1 #define NUM_DEBOUNCE_CHECKS 10 #define NUM_DISP_TEXT_LINE 4 void initDevice(void);

#include #include #include #include #define DCO_FREQ 48e6 #define TIMERO_FREQ 1 #define SYSTICK_FREQ 200 #define RED_LED GPIO_PINO #define GREEN_LED GPIO_PIN1 #define BLUE_LED GPIO_PIN2 #define BUTTON_S1 GPIO_PIN1 #define NUM_DEBOUNCE_CHECKS 10 #define NUM_DISP_TEXT_LINE 4 void initDevice(void); void initGPIO(void); void initTimer(void); void initUART(void): void uarto_transmitStr(const char *str): uint32_t clockMCLK uint8_t currentLED = RED_LED; volatile uint32_t button Statelndex; volatile uint32_t buttonS1_pressed = 0; const char *terminal DisplayText[NUM_DISP_TEXT_LINE] = ", "UART and User Button Demo rin", "R: red, G: green, B:blue, H: Helpir ", void main(void) uint32_t i; uint8_t data; initDevice(); initGPIO : initTimer(); initUART(): Interrupt_enableMaster(); Timer32_startTimer(TIMER32_0_BASE, false): for(i=0; i"); break; case 'G": case 'g': currentLED = GREEN_LED; uarto_transmitStr("Blink green LED. >"); break; case 'B': case 'b': currentLED = BLUE_LED; uarto_transmitStr("Blink blue LED. >"); break; case 'H': case "h: for(i=0; i"); void initDevice(void) WDT_A_hold Timer(); PCM_setPower State(PCM_AM_LDO_VCORE1); FlashCtl_setWaitState(FLASH_BANKO, 1); FlashCtl_setWaitState(FLASH_BANK1, 1); FPU_enableModule(); CS_setDCOFrequency(DCO_FREQ); CS_initClock Signal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK DIVIDER_1); CS_initClockSignal(CS_HSMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_8); CS_initClock Signal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_16); clockMCLK = CS_getMCLKO: void initGPIO(void) GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PINO GPIO_PIN1|GPIO_PIN2); GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1): GPIO_clearlnterruptFlag(GPIO_PORT_P1, GPIO_PIN1); GPIO_interruptEdgeSelect(GPIO_PORT_P1, GPIO_PIN1, GPIO_HIGH_TO_LOW_TRANSITION): GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1); Interrupt_enableInterrupt(INT_PORT1); void initTimer(void) Timer32_initModule(TIMER32_0_BASE, TIMER32_PRESCALER_1, TIMER32_32BIT, TIMER32 PERIODIC MODE); Timer32_setCount(TIMER32_O_BASE, clockMCLK/TIMERO_FREQ); Timer32_enableInterrupt(TIMER32_O_BASE): Interrupt_enableInterrupt(INT_T32_INT1); SysTick_setPeriod (clockMCLKISYSTICK_FREQ); void initUART(void) const USCI_UART_Config config = EUSCI_A_UART_CLOCKSOURCE_SMCLK, 19. EUSCI_A_UART_NO_PARITY, EUSCI A UART LSB FIRST, EUSCI_A_UART_ONE_STOP_BIT, EUSCI_A_UART_MODE, EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION GPIO_setAsPeripheral ModuleFunctioninputPin(GPIO_PORT_P1, GPIO_PINGPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION); UART_initModule(EUSCI_AO_BASE, &config); UART_enableModule(EUSCI_AO_BASE); void uarto_transmitStr(const char *str) uint32_t len, i=0; len = strlen(str); while(i VAL = 0; SysTick_enableModule(); SysTick_enableInterrupt(); void SysTick_Handler(void) uint8_t button State; buttonState = GPIO_getInputPinValue(GPIO_PORT_P1, BUTTON_S1); button State = BUTTON_S1 & (-buttonState); button Statelndex++; if((buttonState & BUTTON_S1) == 0) SysTick_disableInterrupt(); SysTick_disableModule(); else if(button Statelndex >= NUM_DEBOUNCE_CHECKS) SysTick_disableInterrupt(); SysTick_disableModule(); buttonS1_pressed = 1; #include #include #include #include #define DCO_FREQ 48e6 #define TIMERO_FREQ 1 #define SYSTICK_FREQ 200 #define RED_LED GPIO_PINO #define GREEN_LED GPIO_PIN1 #define BLUE_LED GPIO_PIN2 #define BUTTON_S1 GPIO_PIN1 #define NUM_DEBOUNCE_CHECKS 10 #define NUM_DISP_TEXT_LINE 4 void initDevice(void); void initGPIO(void); void initTimer(void); void initUART(void): void uarto_transmitStr(const char *str): uint32_t clockMCLK uint8_t currentLED = RED_LED; volatile uint32_t button Statelndex; volatile uint32_t buttonS1_pressed = 0; const char *terminal DisplayText[NUM_DISP_TEXT_LINE] = ", "UART and User Button Demo rin", "R: red, G: green, B:blue, H: Helpir ", void main(void) uint32_t i; uint8_t data; initDevice(); initGPIO : initTimer(); initUART(): Interrupt_enableMaster(); Timer32_startTimer(TIMER32_0_BASE, false): for(i=0; i"); break; case 'G": case 'g': currentLED = GREEN_LED; uarto_transmitStr("Blink green LED. >"); break; case 'B': case 'b': currentLED = BLUE_LED; uarto_transmitStr("Blink blue LED. >"); break; case 'H': case "h: for(i=0; i"); void initDevice(void) WDT_A_hold Timer(); PCM_setPower State(PCM_AM_LDO_VCORE1); FlashCtl_setWaitState(FLASH_BANKO, 1); FlashCtl_setWaitState(FLASH_BANK1, 1); FPU_enableModule(); CS_setDCOFrequency(DCO_FREQ); CS_initClock Signal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK DIVIDER_1); CS_initClockSignal(CS_HSMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_8); CS_initClock Signal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_16); clockMCLK = CS_getMCLKO: void initGPIO(void) GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PINO GPIO_PIN1|GPIO_PIN2); GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1): GPIO_clearlnterruptFlag(GPIO_PORT_P1, GPIO_PIN1); GPIO_interruptEdgeSelect(GPIO_PORT_P1, GPIO_PIN1, GPIO_HIGH_TO_LOW_TRANSITION): GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1); Interrupt_enableInterrupt(INT_PORT1); void initTimer(void) Timer32_initModule(TIMER32_0_BASE, TIMER32_PRESCALER_1, TIMER32_32BIT, TIMER32 PERIODIC MODE); Timer32_setCount(TIMER32_O_BASE, clockMCLK/TIMERO_FREQ); Timer32_enableInterrupt(TIMER32_O_BASE): Interrupt_enableInterrupt(INT_T32_INT1); SysTick_setPeriod (clockMCLKISYSTICK_FREQ); void initUART(void) const USCI_UART_Config config = EUSCI_A_UART_CLOCKSOURCE_SMCLK, 19. EUSCI_A_UART_NO_PARITY, EUSCI A UART LSB FIRST, EUSCI_A_UART_ONE_STOP_BIT, EUSCI_A_UART_MODE, EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION GPIO_setAsPeripheral ModuleFunctioninputPin(GPIO_PORT_P1, GPIO_PINGPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION); UART_initModule(EUSCI_AO_BASE, &config); UART_enableModule(EUSCI_AO_BASE); void uarto_transmitStr(const char *str) uint32_t len, i=0; len = strlen(str); while(i VAL = 0; SysTick_enableModule(); SysTick_enableInterrupt(); void SysTick_Handler(void) uint8_t button State; buttonState = GPIO_getInputPinValue(GPIO_PORT_P1, BUTTON_S1); button State = BUTTON_S1 & (-buttonState); button Statelndex++; if((buttonState & BUTTON_S1) == 0) SysTick_disableInterrupt(); SysTick_disableModule(); else if(button Statelndex >= NUM_DEBOUNCE_CHECKS) SysTick_disableInterrupt(); SysTick_disableModule(); buttonS1_pressed = 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!