Question: #include #include inc/tm4c123gh6pm.h void SysTick_Init(void); void SysTick_Wait(uint32_t delay); void SysTick_Wait10ms(uint32_t delay); #define NVIC_ST_CTRL_COUNT 0x00010000 // Count flag #define NVIC_ST_CTRL_CLK_SRC 0x00000004 // Clock Source #define NVIC_ST_CTRL_INTEN

#include

#include "inc/tm4c123gh6pm.h"

void SysTick_Init(void);

void SysTick_Wait(uint32_t delay);

void SysTick_Wait10ms(uint32_t delay);

#define NVIC_ST_CTRL_COUNT 0x00010000 // Count flag

#define NVIC_ST_CTRL_CLK_SRC 0x00000004 // Clock Source

#define NVIC_ST_CTRL_INTEN 0x00000002 // Interrupt enable

#define NVIC_ST_CTRL_ENABLE 0x00000001 // Counter mode

#define NVIC_ST_RELOAD_M 0x00FFFFFF // Counter load value

int main(void){

SYSCTL_RCGCGPIO_R |= 0x08; // activate port

SysTick_Init(); // initialize SysTick timer

GPIO_PORTF_DIR_R |= 0x08; // make PF3 out (built-in blue LED)

GPIO_PORTF_AFSEL_R &= ~0x08;// disable alt funct on PD3

GPIO_PORTF_DEN_R |= 0x08; // enable digital I/O on PD3

// configure PD3 as GPIO

GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF0FF) +0x00000000;

GPIO_PORTF_AMSEL_R = 0; // disable analog functionality on PD

while(1){

GPIO_PORTF_DATA_R = GPIO_PORTF_DATA_R^0x08; // toggle PD3

// SysTick_Wait(1); // approximately 1000 ns

// SysTick_Wait(2); // approximately 1000 ns

// SysTick_Wait(10000); // approximately 2 ms

SysTick_Wait10ms(1); // approximately 10 ms

}

}

// Initialize SysTick with busy wait running at bus clock

void SysTick_Init(void){

NVIC_ST_CTRL_R =0; //disable systick during setup

NVIC_ST_RELOAD_R = NVIC_ST_RELOAD_M; // maxium reload value

NVIC_ST_CURRENT_R =0; // any write to current cleat it

// enablle SysTick with core clock

NVIC_ST_CTRL_R = NVIC_ST_CTRL_ENABLE + NVIC_ST_CTRL_CLK_SRC;

}

//Time delay using busy wait

//The delay parameter is in units of the core clock.(units of 20 nsec for 50mhz clock)

void SysTick_Wait(uint32_t delay){

volatile uint32_t elapsedTime;

uint32_t startTime = NVIC_ST_CURRENT_R;

do{

elapsedTime = (startTime-NVIC_ST_CURRENT_R)& 0x00FFFFFF;

}

while(elapsedTime <= delay);

}

// Time delay using busy wait

//This assumes 50 KHZ system clock

void SysTick_Wait10ms(uint32_t delay){

unsigned long i;

for(i=0; i

SysTick_Wait(800000); // wait 10ms

}

}

need help, in this code, how to fix it to fit this requirement?

thank you

Build a system that a tactile switch connects to port D pin 3 (PD3) and PD0 connects a LED. If switch is OFF, LED turns OFF. If switch is ON, LED turns ON.utilize SysTick Timer code

if button is pressed, LED blinks.

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

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!