Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Coding help for MSP432 launchpad Create a new CCS project with the sample code Lab3_3_main.c. This sample code implements a software glitch filtering for user

Coding help for MSP432 launchpad Create a new CCS project with the sample code Lab3_3_main.c.  This sample code implements a software glitch filtering for user button S1.  Compile and run the program. Study the source code.  The user button S2 is connected to P1.4, which has glitch filtering capability built-in. In order to enable glitch filter, you will need to call the following function when configuring the GPIO port: void SysCtl_enableGlitchFilter(void);  Modify the source code to implement the following features: o Click button S1 to double the LED blinking frequency. o Click button S2 to decrease the LED blinking frequency by half. o Define a minimum (2-4 Hz) and a maximum (24 Hz) blinking frequencies to prevent the blinking frequency from being increased or decreased indefinitely by user 
#include  #include  #include  //Exact-width integer types #include  //Driver library #define DCO_FREQ 48e6 //unit: Hz; DCO nominal frequencies: 1.5, 3, 6, 12, 24, 48 MHz. #define TIMER0_FREQ 1 //unit: Hz #define SYSTICK_FREQ 200 //unit: Hz #define RED_LED GPIO_PIN0 #define GREEN_LED GPIO_PIN1 #define BLUE_LED GPIO_PIN2 #define BUTTON_S1 GPIO_PIN1 #define NUM_DEBOUNCE_CHECKS 10 //For 50 msec debounce time. #define NUM_DISP_TEXT_LINE 4 //function prototypes void initDevice(void); void initGPIO(void); void initTimer(void); void initUART(void); void uart0_transmitStr(const char *str); // global variables uint32_t clockMCLK; uint8_t currentLED = RED_LED; volatile uint32_t buttonStateIndex; const char *terminalDisplayText[NUM_DISP_TEXT_LINE] = { " ", "UART and User Button Demo ", "R: red, G: green, B:blue, H: Help ", "> " }; void main(void) { uint32_t i; uint8_t data; initDevice(); initGPIO(); initTimer(); initUART(); Interrupt_enableMaster(); Timer32_startTimer(TIMER32_0_BASE, false); // Initial display on terminal. for(i=0; i "); break; case 'G': case 'g': currentLED = GREEN_LED; uart0_transmitStr("Blink green LED. > "); break; case 'B': case 'b': currentLED = BLUE_LED; uart0_transmitStr("Blink blue LED. > "); break; case 'H': case 'h': for(i=0; i "); buttonStateIndex = 0; SysTick->VAL = 0; //To cause immediate reload to SysTick counter. SysTick_enableModule(); //Enable and start the SysTick counter. SysTick_enableInterrupt(); } } //SysTick ISR void SysTick_Handler(void) { uint8_t buttonState; //P1.1 is configured with a pull-up resistor, so P1.1 = 0 when pressed. //buttonState = 1 when pressed, which is opposite to P1.1 value. buttonState = GPIO_getInputPinValue(GPIO_PORT_P1, BUTTON_S1); buttonState = BUTTON_S1 & (~buttonState); buttonStateIndex++; if((buttonState & BUTTON_S1) == 0) { SysTick_disableInterrupt(); SysTick_disableModule(); } else if(buttonStateIndex >= NUM_DEBOUNCE_CHECKS) { //Button S1 is pressed SysTick_disableInterrupt(); SysTick_disableModule(); uart0_transmitStr("Button S1 is pressed. > "); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

Explain exothermic and endothermic reactions with examples

Answered: 1 week ago