0% found this document useful (0 votes)
13 views3 pages

LM3S6965

The document discusses GPIO and interrupt handling on the LM3S6965 microcontroller. It explains that interrupt handlers must be defined in startup_rvmdk.S and clear the interrupt by writing to the GPIO_PORTX_ICR register. It also describes how to configure GPIO ports by giving clock using SYSCTL_RCGC2, enabling pins using GPIO_PORTX_DEN, setting direction using GPIO_PORTX_DIR, and optionally configuring pull-up and drive using GPIO_PORTX_PUR and GPIO_PORTX_DR8R.

Uploaded by

WanBi Ta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

LM3S6965

The document discusses GPIO and interrupt handling on the LM3S6965 microcontroller. It explains that interrupt handlers must be defined in startup_rvmdk.S and clear the interrupt by writing to the GPIO_PORTX_ICR register. It also describes how to configure GPIO ports by giving clock using SYSCTL_RCGC2, enabling pins using GPIO_PORTX_DEN, setting direction using GPIO_PORTX_DIR, and optionally configuring pull-up and drive using GPIO_PORTX_PUR and GPIO_PORTX_DR8R.

Uploaded by

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

LM3S6965

1. Interrupt:
- For doing the Handler after interrupt, we should define the Handler in startup_rvmdk.S.
- When into the Handler, we should clear the interrupt by using
GPIO_PORTX_ICR_R
Writing a bit 1 in this register clear the corresponding interrupt edge detection logic register.
Writing a bit 0 has no effect.- Sau thc thi on code mnh mong mun.
- Example:
void
INTGPIOF(void)
{
// Clear the interrupt at F.1
GPIO_PORTF_ICR |= 0x02;
.
}
II. GPIO:
- When we want to use any PORT or GPIO, we need to give clock to that PORT by using:
SYSCTL_RCGC2_R |=
- Here are the software definitions for PORT:
+ SYSCTL_RCGC2_GPIOA

0x00000001

// Port A Clock Gating Control

+ SYSCTL_RCGC2_GPIOG

0x00000040

// Port G Clock Gating Control

+ SYSCTL_RCGC2_GPIOF

0x00000020

// Port F Clock Gating Control

+ SYSCTL_RCGC2_GPIOE

0x00000010

// Port E Clock Gating Control

+ SYSCTL_RCGC2_GPIOD

0x00000008

// Port D Clock Gating Control

+ SYSCTL_RCGC2_GPIOC

0x00000004

// Port C Clock Gating Control

+ SYSCTL_RCGC2_GPIOB

0x00000002

// Port B Clock Gating Control

- Example:
int
main(void)
{
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF;
}

// Give clock for PORT F

- Then we must set the Digital Enable Register- GPIODEN. By default, with the exception of
the GPIO signals is used for JTAG/SWD function, all other GPIO signals are configured to be
undriven. Their digital function is disabled which mean that they do not drive a logic value on
the pin and they do not alow the pin voltage into the GPIO reciever. To use the pin in digital
function we must use:
GPIO_PORTX_DEN_R =
- Example:
int
main(void)
{
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF;
GPIO_PORTF_DEN_R |= ((1<<0)|(1<<1));
}

// Give clock for PORT F


// Enable port F.0 F.1

- After that we must set the Data Direction Registers GPIODIR, bit set to 1 in the
GPIODIR register configure the corresponding pin to be output, while bits set to 0 configure the
pin to be inbut. By default, all GPIO pins are input.
GPIO_PORTX_DIR_R
- Example:
int
main(void)
{
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF;
GPIO_PORTF_DEN_R |= ((1<<0)|(1<<1));
GPIO_PORTF_DIR_R &= ~(1<<1);
GPIO_PORTF_DIR_R |= (0x1);
}

// Give clock for PORT F


// Enable port F.0 F.1
// Set F.1 IN
// Set F.0 OUT

- Then, if we want to use the Switch, we must configure the Pull-up Register GPIOPUR and
8-mA or 4-mA or 2-mA Drive Control Register GPIODR8R GPIODR4R GPIODR2R
for the corresponding pin of Switch.
GPIO_PORTX_DR8R_R
GPIO_PORTX_PUR_R
- Example:
int
main(void)
{
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF;
GPIO_PORTF_DEN_R |= ((1<<0)|(1<<1));
GPIO_PORTF_DIR_R &= ~(1<<1);
GPIO_PORTF_DIR_R |= (0x1);
GPIO_PORTF_PUR_R |= (1<<1);
GPIO_PORTF_DR8R_R |= (1<<1);
}

// Give clock for PORT F


// Enable port F.0 F.1
// Set F.1 IN
// Set F.0 OUT
// Set F.1 PULL UP
// Set F.1 8mA

You might also like