Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use same switch circuit, port, and pins, utilize SysTick Timer code (the one below) to modify HW3 code so that -if the button is pressed,

Use same switch circuit, port, and pins, utilize SysTick Timer code (the one below) to modify HW3 code so that

-if the button is pressed, LED blinks.

-If the button is not pressed, the LED is just on.

Thank you, the following code just needs to be adjusted so that the conditions above are met thank you again.

// SysTickTestMain.c // Runs on TM4C1294 // Test the SysTick functions by activating the PLL, initializing the // SysTick timer, and flashing an LED at a constant rate. // Daniel Valvano // April 3, 2014

/* This example accompanies the books "Embedded Systems: Introduction to ARM Cortex M Microcontrollers", ISBN: 978-1469998749, Jonathan Valvano, copyright (c) 2014 Volume 1, Program 4.7

"Embedded Systems: Real Time Interfacing to Arm Cortex M Microcontrollers", ISBN: 978-1463590154, Jonathan Valvano, copyright (c) 2014 Program 2.11, Section 2.6

Copyright 2014 by Jonathan W. Valvano, valvano@mail.utexas.edu You may use, edit, run or distribute this file as long as the above copyright notice remains THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. VALVANO SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. For more information about my classes, my research, and my books, see http://users.ece.utexas.edu/~valvano/ */

// PN1 is an output for debugging

#include #include "SysTick.h" #include "PLL.h"

#define GPIO_PORTN_DATA_R (*((volatile uint32_t *)0x400643FC)) #define GPIO_PORTN_DIR_R (*((volatile uint32_t *)0x40064400)) #define GPIO_PORTN_AFSEL_R (*((volatile uint32_t *)0x40064420)) #define GPIO_PORTN_DEN_R (*((volatile uint32_t *)0x4006451C)) #define GPIO_PORTN_AMSEL_R (*((volatile uint32_t *)0x40064528)) #define GPIO_PORTN_PCTL_R (*((volatile uint32_t *)0x4006452C)) #define SYSCTL_RCGCGPIO_R (*((volatile uint32_t *)0x400FE608)) #define SYSCTL_RCGCGPIO_R12 0x00001000 // GPIO Port N Run Mode Clock // Gating Control #define SYSCTL_PRGPIO_R (*((volatile uint32_t *)0x400FEA08)) #define SYSCTL_PRGPIO_R12 0x00001000 // GPIO Port N Peripheral Ready

int main(void){ PLL_Init(); // set system clock to 120 MHz SysTick_Init(); // initialize SysTick timer // activate clock for Port N SYSCTL_RCGCGPIO_R |= SYSCTL_RCGCGPIO_R12; // allow time for clock to stabilize while((SYSCTL_PRGPIO_R&SYSCTL_PRGPIO_R12) == 0){}; GPIO_PORTN_DIR_R |= 0x02; // make PN1 out (PN1 built-in LED1) GPIO_PORTN_AFSEL_R &= ~0x02;// disable alt funct on PN1 GPIO_PORTN_DEN_R |= 0x02; // enable digital I/O on PN1 // configure PN1 as GPIO GPIO_PORTN_PCTL_R = (GPIO_PORTN_PCTL_R&0xFFFFFF0F)+0x00000000; GPIO_PORTN_AMSEL_R &= ~0x02;// disable analog functionality on PN1 while(1){ GPIO_PORTN_DATA_R = GPIO_PORTN_DATA_R^0x02; // toggle PN1 // SysTick_Wait(1); // approximately 516 ns // SysTick_Wait(2); // approximately 516 ns // SysTick_Wait(10000); // approximately 0.08333 ms SysTick_Wait10ms(10); // approximately 100 ms } }

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

More Books

Students also viewed these Databases questions

Question

2. How should this be dealt with by the organisation?

Answered: 1 week ago

Question

explain what is meant by the term fair dismissal

Answered: 1 week ago