Академический Документы
Профессиональный Документы
Культура Документы
Pi19404
November 21, 2013
Contents
Contents
Embedded Systems Programming with ARM on Linux- Blinking LED 3
0.1 Introduction . . . . . . . . . . . . . . 0.2 Installations and Setup . . . . . . 0.2.1 Software Installations . 0.2.2 Setup . . . . . . . . . . . . . . 0.2.3 Programming the ARM GPIO Pins . . . . . . . . . . . 0.3 Code . . . . . . . . . . . . . . . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
3 3 4 4 8 9 9
2 | 10
3 | 10
Download the stellarisware windows software http://www.ti. com/tool/sw-lm3s. Inflate the windows archive by unzipping the exe file. The examples for present board are located at $ARCHIVE_HOME/examples/boa lm4f232 Power the board using ICDI USB Cable from the PC,check if the board is detected . Run the lsusb command and check if Luminary Micro Inc is found
0.2.2 Setup
Create a new project
4 | 10
5 | 10
6 | 10
compiled and .bin file is created in the build directory run the command lm4flash project1.bin to program the microcontroller.
7 | 10
The board contains one user LED.In this first example we will write a program to toggle this user LED one and off. We can find the detailed schematic at the end of the manual and figure 1f We can see that pin PG2 (pin 2 of port G is connected
8 | 10
Embedded Systems Programming with ARM on Linux- Blinking LED to the user LED)
GPIO Pins The GPIO or general purpose input and output pins are easiest way to interact with peripherals like buttons,LEDs,switches and other components etc. The GPIO pins are controlled by the following registers.
GPIODIR - DPIO direction register is used to configure each individual pins as input or output GPIODATA - GPIO data allows for modification of data in individual GPIO registers without affecting the state of the other pins. GPIODEN - GPIO Digital enable register,enables the use of GPIO pin as digital pin
These macros corresponding to registers can be found in lm4f232hqd.h header file found in StelarrisWare include Directory are GPIO_PORTG_DATA_R,GPIO_PORTG_DIR_R and GPIO_PORTG_DEN_R respectively.
0.3 Code
1 2 3 4 5 6 7
#include <stdint.h> #include "lm4f232h5qd.h" int main(void) { volatile uint32_t ui32Loop; // Enable the GPIO pin for the LED (PG2). Set the direction as output, and // enable the GPIO pin for digital function. //
9 | 10
GPIO_PORTG_DIR_R = 0x04; GPIO_PORTG_DEN_R = 0x04; while(1) { // // Turn on the LED. // GPIO_PORTG_DATA_R |= 0x04; // // Delay for a bit. // for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++) { } // // Turn off the LED. // GPIO_PORTG_DATA_R &= ~(0x04); // // Delay for a bit. // for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++) { } } e code can also be found in GIT Repository rl{https://github.com/pi19404/m19404/tree/master/Embedded/blinkLED_ARM}
10 | 10