Académique Documents
Professionnel Documents
Culture Documents
NOTE
1. Include following header files in your main.c
#include "inc/hw_memmap.h" //Macros defining memory map of the device
#include "driverlib/sysctl.h" //Prototypes for the system control driver
#include "driverlib/gpio.h" //GPIO API
2. GPIOs on TM4C123 can be configured for 2mA, 4mA, 8mA drive strength. On reset,
GPIOs are default to 2mA drive strength. While interfacing LEDs, if the LED current is
more than 8mA then we cannot connect it directly to the microcontroller pin. It mat
damage the chip due to high current.
3. Use 7406 buffer to avoid accidental damage to microcontroller pins.
There are some basic functions for reading a pin value and writing to a pin of TM4C123.
Following examples are included to help you understand these two function better:
1. int32_t GPIOPinRead(uint32_t ui32Port,uint8_t ui8Pins)
ui32Port is the base address of the GPIO port.
ui8Pins is the bit packet representation of the pin(s).
For example,
int32_t PinE7 = GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_7);
Above statement reads pin 7 value of Port A and stores it in a variable PinE7.
Note that this function returns a bit-packed byte.
If Pin 7 is LOW then PinE7 = 0
If Pin 7 is HIGH then PinE7 = 128
2. void GPIOPinWrite(uint32_t ui32Port, uint8_t ui8Pins, uint8_t ui8Val)
Again, ui32Port is the base address of the GPIO port and ui8Pins is the bit packet
representation of the pin(s).
ui8Val is the value to write to the pin(s).
For example,
GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4|GPIO_PIN_3, 24);
Above statement assigns HIGH value to Pin 3 and Pin 4 of Port E. (24)10=(00011000)2
For more information on API functions, Please refer TivaWare Peripheral Driver Library user
guide on lab webpage.
References
1. http://users.ece.utexas.edu/~valvano/Volume1/E-Book/C8_SwitchLED.htm
2. http://processors.wiki.ti.com/index.php/Introduction_to_the_TIRTOS_Kernel_Workshop