Difference between revisions of "TM4C123 GPIO Port Interrupt Tasks"

From EdWiki

(Created page with "__NOTOC__ == Tasks == === 1. Sample program (SW1 Interrupt) === * Create a CCS Project with "Empty Project" * Download [{{SERVER}}/emsys/tivac/sw1_int.c <big>sw1_int.c</big>]...")
Line 1: Line 1:
== GPIO Interrupt Programming Tasks ==
== Tasks ==
=== 1. Sample program (SW1 Interrupt) ===
=== 1. Sample program (SW1 Interrupt) ===
* Create a CCS Project with "Empty Project"
* Create a CCS Project with "Empty Project"

Revision as of 05:15, 5 February 2019

GPIO Interrupt Programming Tasks

1. Sample program (SW1 Interrupt)

  • Create a CCS Project with "Empty Project"
  • Download sw1_int.c program and Add this file to your project.
  • Open tm4c123gh6pm_startup_ccs_gcc.c for editing and replace IntDefaultHandler with the GPIOPortF_Handler in the GPIO Port F vector position.
  • Build and Debug (Run) the program.
    Run this code and load it into the flash of microcontroller. You will see that the blue LED gets turned on when user switch is pressed first then if it is pressed again it gets turned off.

2. Multiple Interrupts of the same Portx

  • Rewrite the above program (sw1_int.c) to distinguish between various pins of PortF. If pressed SW1 (PF4), toggle the green LED (PF3) and when SW2 (PF0) is pressed blue LED (PF2) should toggle.

3. Interrupt from External Source

  • Write a program to toggle an LED at the same rate as the input frequency by connecting a square wave of 3.3V to a pin of Portx. (You can make it to toggle on positive or negative edge or both)

4. UART0 Interrupt Programming to receive data

  • UART0 Echo Program showed how UART0 receives data by polling the RXFE status flag. The disadvantage with that program is that it ties down the CPU polling the status flag. Modify it to make it an interrupt driven program.
    Hint: Examining the UARTIM (UART Interrupt Mask) register, we see bit 4 allows us to enable the receive interrupt. If the receive interrupt for UART is enabled, when a byte is received, the receive flag is directed to NVIC and that causes the interrupt handler associated with the UART0 to be executed. In the UART0 handler we must read the received byte and clear the interrupt flag.

5. Using SysTick with Interrupt

  • Setup the SysTick to interrupt at 1 Hz (Assume the system clock is running at 16 Mhz). Toggle the Red LED using the SysTick interrupt.
    Hint: The SysTick timer was discussed here. If INTEN=1, when the COUNT flag is set, it causes an interrupt via the NVIC. INTEN is D1 of the STCTRL register.