I have already done most of this work I just need help troubleshooting it is an arm based board  /*KL25Z_LED_Blinky.c*/ #include /* provides fixed width integer types. For example, uint32_t) */ #include "derivative.h" /* KL25Z info */ #include "mcg.h" /* main clock generator */ #include "systick.h" /* SysTick timer */ #include "KL25Z_gpio.h" /* GPIO routines */ #include "KL25Z_port.h" /* PORT routines */ #include "delays.h" /* software based delays */ /* Macro definitions */ #define RED_LED_PIN 18 /* GPIO and PORT module "pins", not the device pins */ #define GREEN_LED_PIN 19 #define BLUE_LED_PIN 1 #define LED_OFF 1 #define LED_ON 0 /* Globals */ volatile uint32_t sysTicks; int main(void) { int k; pll_init(8000000,0,1,4,24,1); sysTicks = 0; initSysTicks(); enable_port_clock(PORTB_PERIPHERAL); enable_port_clock(PORTD_PERIPHERAL); /* set signal multiplexing for GPIOs to the LEDs */ set_port_mux(PORTB_PERIPHERAL, RED_LED_PIN, ALT1); set_port_mux(PORTB_PERIPHERAL, GREEN_LED_PIN, ALT1); set_port_mux(PORTD_PERIPHERAL, BLUE_LED_PIN, ALT1); /* setup pin circuits. There are no pulldown resistors on a KL25Z */ disable_port_pin_high_drive(PORTB_PERIPHERAL, RED_LED_PIN); disable_port_pin_filter(PORTB_PERIPHERAL, RED_LED_PIN); select_port_pin_slow_slew(PORTB_PERIPHERAL, RED_LED_PIN); disable_port_pin_pull_resistor(PORTB_PERIPHERAL, RED_LED_PIN); disable_port_pin_high_drive(PORTB_PERIPHERAL, GREEN_LED_PIN); disable_port_pin_filter(PORTB_PERIPHERAL, GREEN_LED_PIN); select_port_pin_slow_slew(PORTB_PERIPHERAL, GREEN_LED_PIN); disable_port_pin_pull_resistor(PORTB_PERIPHERAL, GREEN_LED_PIN); disable_port_pin_high_drive(PORTD_PERIPHERAL, BLUE_LED_PIN); disable_port_pin_filter(PORTD_PERIPHERAL, BLUE_LED_PIN); select_port_pin_slow_slew(PORTD_PERIPHERAL, BLUE_LED_PIN); disable_port_pin_pull_resistor(PORTD_PERIPHERAL, BLUE_LED_PIN); /* setup the GPIO */ init_gpio_pin(GPIOB_PERIPHERAL, RED_LED_PIN, GPIO_OUT); init_gpio_pin(GPIOB_PERIPHERAL, GREEN_LED_PIN, GPIO_OUT); init_gpio_pin(GPIOD_PERIPHERAL, BLUE_LED_PIN, GPIO_OUT); set_gpio_pin_level(GPIOB_PERIPHERAL, RED_LED_PIN, LED_OFF); set_gpio_pin_level(GPIOB_PERIPHERAL, GREEN_LED_PIN, LED_OFF); set_gpio_pin_level(GPIOD_PERIPHERAL, BLUE_LED_PIN, LED_OFF); // Turn on red if k is between 0 and 10 if(k >= 0 && k <= 10) set_gpio_pin_level(GPIOB_PERIPHERAL, RED_LED_PIN, LED_ON); // Turn on green if k is between 10 and 20 if(k > 10 && k <=20) set_gpio_pin_level(GPIOB_PERIPHERAL, GREEN_LED_PIN, LED_ON); // Turn on blue if k is between 20 and 30 if(k > 20 && k <= 30) set_gpio_pin_level(GPIOB_PERIPHERAL, BLUE_LED_PIN, LED_ON); if(k >30 && k <= 100) { for(;;){ set_gpio_pin_level(GPIOB_PERIPHERAL, RED_LED_PIN, LED_ON); delay_sec(3); set_gpio_pin_level(GPIOB_PERIPHERAL, RED_LED_PIN, LED_OFF); delay_sec(1); set_gpio_pin_level(GPIOB_PERIPHERAL, GREEN_LED_PIN, LED_ON); delay_sec(3); set_gpio_pin_level(GPIOB_PERIPHERAL, GREEN_LED_PIN, LED_OFF); delay_sec(1); set_gpio_pin_level(GPIOB_PERIPHERAL, BLUE_LED_PIN, LED_ON); delay_sec(3); set_gpio_pin_level(GPIOB_PERIPHERAL, BLUE_LED_PIN, LED_OFF); delay_sec(1); } } return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I have already done most of this work I just need help troubleshooting it is an arm based board 

/*KL25Z_LED_Blinky.c*/

#include <stdint.h> /* provides fixed width integer types. For example, uint32_t) */
#include "derivative.h" /* KL25Z info */
#include "mcg.h" /* main clock generator */
#include "systick.h" /* SysTick timer */
#include "KL25Z_gpio.h" /* GPIO routines */
#include "KL25Z_port.h" /* PORT routines */
#include "delays.h" /* software based delays */

/* Macro definitions */
#define RED_LED_PIN 18 /* GPIO and PORT module "pins", not the device pins */
#define GREEN_LED_PIN 19
#define BLUE_LED_PIN 1
#define LED_OFF 1
#define LED_ON 0

/* Globals */
volatile uint32_t sysTicks;

int main(void) {

int k;

pll_init(8000000,0,1,4,24,1);
sysTicks = 0;
initSysTicks();
enable_port_clock(PORTB_PERIPHERAL);
enable_port_clock(PORTD_PERIPHERAL);

/* set signal multiplexing for GPIOs to the LEDs */
set_port_mux(PORTB_PERIPHERAL, RED_LED_PIN, ALT1);
set_port_mux(PORTB_PERIPHERAL, GREEN_LED_PIN, ALT1);
set_port_mux(PORTD_PERIPHERAL, BLUE_LED_PIN, ALT1);

/* setup pin circuits. There are no pulldown resistors on a KL25Z */
disable_port_pin_high_drive(PORTB_PERIPHERAL, RED_LED_PIN);
disable_port_pin_filter(PORTB_PERIPHERAL, RED_LED_PIN);
select_port_pin_slow_slew(PORTB_PERIPHERAL, RED_LED_PIN);
disable_port_pin_pull_resistor(PORTB_PERIPHERAL, RED_LED_PIN);

disable_port_pin_high_drive(PORTB_PERIPHERAL, GREEN_LED_PIN);
disable_port_pin_filter(PORTB_PERIPHERAL, GREEN_LED_PIN);
select_port_pin_slow_slew(PORTB_PERIPHERAL, GREEN_LED_PIN);
disable_port_pin_pull_resistor(PORTB_PERIPHERAL, GREEN_LED_PIN);

disable_port_pin_high_drive(PORTD_PERIPHERAL, BLUE_LED_PIN);
disable_port_pin_filter(PORTD_PERIPHERAL, BLUE_LED_PIN);
select_port_pin_slow_slew(PORTD_PERIPHERAL, BLUE_LED_PIN);
disable_port_pin_pull_resistor(PORTD_PERIPHERAL, BLUE_LED_PIN);

/* setup the GPIO */
init_gpio_pin(GPIOB_PERIPHERAL, RED_LED_PIN, GPIO_OUT);
init_gpio_pin(GPIOB_PERIPHERAL, GREEN_LED_PIN, GPIO_OUT);
init_gpio_pin(GPIOD_PERIPHERAL, BLUE_LED_PIN, GPIO_OUT);

set_gpio_pin_level(GPIOB_PERIPHERAL, RED_LED_PIN, LED_OFF);
set_gpio_pin_level(GPIOB_PERIPHERAL, GREEN_LED_PIN, LED_OFF);
set_gpio_pin_level(GPIOD_PERIPHERAL, BLUE_LED_PIN, LED_OFF);


// Turn on red if k is between 0 and 10
if(k >= 0 && k <= 10)
set_gpio_pin_level(GPIOB_PERIPHERAL, RED_LED_PIN, LED_ON);

// Turn on green if k is between 10 and 20
if(k > 10 && k <=20)
set_gpio_pin_level(GPIOB_PERIPHERAL, GREEN_LED_PIN, LED_ON);

// Turn on blue if k is between 20 and 30
if(k > 20 && k <= 30)
set_gpio_pin_level(GPIOB_PERIPHERAL, BLUE_LED_PIN, LED_ON);

if(k >30 && k <= 100)
{
for(;;){
set_gpio_pin_level(GPIOB_PERIPHERAL, RED_LED_PIN, LED_ON);
delay_sec(3);
set_gpio_pin_level(GPIOB_PERIPHERAL, RED_LED_PIN, LED_OFF);
delay_sec(1);
set_gpio_pin_level(GPIOB_PERIPHERAL, GREEN_LED_PIN, LED_ON);
delay_sec(3);
set_gpio_pin_level(GPIOB_PERIPHERAL, GREEN_LED_PIN, LED_OFF);
delay_sec(1);
set_gpio_pin_level(GPIOB_PERIPHERAL, BLUE_LED_PIN, LED_ON);
delay_sec(3);
set_gpio_pin_level(GPIOB_PERIPHERAL, BLUE_LED_PIN, LED_OFF);
delay_sec(1);
}
}

return 0;
}

Exercise 1:
Modify the program to continuously blink the LEDS in the following pattern.
• Turn on the red LED for 3 seconds.
• Turn off the red LED for 1 seconds.
• Turn on the green LED for 3 seconds.
• Turn off the green LED for 1 seconds.
• Turn on the blue LED for 3 seconds
• Turn off the blue LED for 1 seconds
• Turn on all 3 LEDS at once for 3 seconds. The color should be white.
• Turn off all 3 LEDS for 1 second
• Repeat forever. Go back to Step 1.
Show and explain your work to the professor.
Exercise 2:
Modify the code to prompt the user to enter an integer k between 0 and 100. Then the code to perform the following:
1- The Red LED turns ON, if 0 < k < 10,
2- The Green LED turns ON, if , 10 <k< 20 ,
3- The Blue LED turns ON, if 20 <k< 30,
4- If 30 < k <100, blink the LEDS in the following pattern:
Turn on the red LED for 3 seconds.
• Turn off the red LED for 1 seconds.
• Turn on the green LED for 3 seconds.
• Turn off the green LED for 1 seconds.
• Turn on the blue LED for 3 seconds
• Turn off the blue LED for 1 seconds
Transcribed Image Text:Exercise 1: Modify the program to continuously blink the LEDS in the following pattern. • Turn on the red LED for 3 seconds. • Turn off the red LED for 1 seconds. • Turn on the green LED for 3 seconds. • Turn off the green LED for 1 seconds. • Turn on the blue LED for 3 seconds • Turn off the blue LED for 1 seconds • Turn on all 3 LEDS at once for 3 seconds. The color should be white. • Turn off all 3 LEDS for 1 second • Repeat forever. Go back to Step 1. Show and explain your work to the professor. Exercise 2: Modify the code to prompt the user to enter an integer k between 0 and 100. Then the code to perform the following: 1- The Red LED turns ON, if 0 < k < 10, 2- The Green LED turns ON, if , 10 <k< 20 , 3- The Blue LED turns ON, if 20 <k< 30, 4- If 30 < k <100, blink the LEDS in the following pattern: Turn on the red LED for 3 seconds. • Turn off the red LED for 1 seconds. • Turn on the green LED for 3 seconds. • Turn off the green LED for 1 seconds. • Turn on the blue LED for 3 seconds • Turn off the blue LED for 1 seconds
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education