Question
Question 2: when button SW2 is pressed, the onboard RED LED will be blinking at 4Hz frequency Here is my code for FRDM 64K MCUExpresso
Question 2:
when button SW2 is pressed, the onboard RED LED will be blinking at 4Hz frequency
Here is my code for FRDM 64K MCUExpresso
#include
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "MK64F12.h"
#include "fsl_debug_console.h"
void PIT_CHANNEL_0_IRQHANDLER(void)
{
PIT_ClearStatusFlags(PIT, PIT_CHANNEL_0, kPIT_TimerFlag);
LED_RED_TOGGLE();
LED_GREEN_TOGGLE();
GPIO_PinWrite(GPIOC, 16U, 0U);
}
void SW2_GPIOC_IRQHANDLER(void)
{
GPIO_PinWrite(GPIOC, 16U, 1U);
PRINTF("System status: Armed ");
GPIO_PortClearInterruptFlags(GPIOC, 1U << 6U);
LED_RED_ON();
LED_GREEN_OFF();
}
void SW3_GPIOA_IRQHANDLER(void)
{
GPIO_PinWrite(GPIOC, 16U, 0U);
PRINTF("System status: Disarmed ");
GPIO_PortClearInterruptFlags(GPIOA, 1U << 4U);
LED_RED_OFF();
LED_GREEN_ON();
}
int main(void)
{
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
BOARD_InitDebugConsole();
#endif
LED_RED_OFF();
LED_GREEN_ON();
PRINTF("Press SW2 to Arm System ");
PRINTF("Press SW3 to Disarm System ");
PRINTF("System status: Disarmed ");
volatile static int i = 0 ;
while(1) {
i++ ;
__asm volatile ("nop");
}
return 0 ;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started