You are on page 1of 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