0% found this document useful (0 votes)
139 views1 page

Led C

This C code defines functions to initialize and control an LED connected to port D pin 2 of a TM4C123GH6PM microcontroller. It includes header files related to the microcontroller's GPIO and system control functionality. The InitLED function enables the port D clock, sets the pin as a digital output, and prints a message. The TurnOnLED and TurnOffLED functions set the pin high or low respectively to turn the LED on or off.

Uploaded by

api-272643960
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views1 page

Led C

This C code defines functions to initialize and control an LED connected to port D pin 2 of a TM4C123GH6PM microcontroller. It includes header files related to the microcontroller's GPIO and system control functionality. The InitLED function enables the port D clock, sets the pin as a digital output, and prints a message. The TurnOnLED and TurnOffLED functions set the pin high or low respectively to turn the LED on or off.

Uploaded by

api-272643960
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

"ES_Configure.h"
"ES_Framework.h"
"ES_DeferRecall.h"
"inc/hw_memmap.h"
"inc/hw_types.h"
"inc/hw_gpio.h"
"inc/hw_sysctl.h"
"driverlib/sysctl.h"
"driverlib/pin_map.h"
"driverlib/gpio.h"
"inc/hw_nvic.h"
"inc/hw_timer.h"

// Define PART_TM4C123GH6PM in project

#include "LED.h"
void InitLED(void)
{
volatile uint32_t Dummy;
// enable the clock to Port F
HWREG(SYSCTL_RCGCGPIO) |= SYSCTL_RCGCGPIO_R3;
// kill a few cycles to let the peripheral clock get going
Dummy = HWREG(SYSCTL_RCGCGPIO);
// Enable pins for digital I/O
HWREG(GPIO_PORTD_BASE+GPIO_O_DEN) |= (GPIO_PIN_2);
// make pins 2 on Port D into outputs
HWREG(GPIO_PORTD_BASE+GPIO_O_DIR) |= (GPIO_PIN_2);
printf("InitLED Complete\r\n");
}
void TurnOnLED(void)
{
//put PD2 high
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + (0xff<<2))) |= GPIO_PIN_2;
}
void TurnOffLED(void)
{
//make PD2 low
HWREG(GPIO_PORTD_BASE+(GPIO_O_DATA + (0xff<<2))) &= ~GPIO_PIN_2;
}

You might also like