Actions

EmSys

Difference between revisions of "TM4C123 GPIO Port Interrupt Tasks"

From EdWiki

m (3. Interrupt from External Source)
m (See Also)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
== GPIO Interrupt Programming 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"
 
* Download [{{SERVER}}/emsys/tivac/sw1_int.c <big>sw1_int.c</big>] program and <big>Add</big> this file to your project.
 
* Download [{{SERVER}}/emsys/tivac/sw1_int.c <big>sw1_int.c</big>] program and <big>Add</big> this file to your project.
* Open tm4c123gh6pm_startup_ccs_gcc.c for editing and replace <u>''IntDefaultHandler''</u> with the ''GPIOPortF_Handler'' in the GPIO Port F vector position.
+
* Open tm4c123gh6pm_startup_ccs_gcc.c for editing and replace <u>''IntDefaultHandler''</u> with the ''GPIOPortF_Handler'' in the GPIO PortF vector position.
 
* Build and Debug (Run) the program.
 
* 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.
 
*: 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. GPIOF interrupt from SW1 and SW2 ===
 
=== 2. GPIOF interrupt from SW1 and SW2 ===
* Rewrite the interrupt handler in [{{SERVER}}/emsys/tivac/sw1_int.c <big>sw1_int.c</big>]) to distinguish the interrupt pin. Toggle Red LED on PF1 continuously. Upon pressing either SW1 or SW2, the Green or Blue LED will toggle three times. main program toggles Red LED while waiting for interrupt from SW1 or SW2.
+
* Rewrite [{{SERVER}}/emsys/tivac/sw1_int.c <big>sw1_int.c</big>] program to distinguish the interrupt pin. Toggle Red LED on PF1 continuously. Upon pressing either SW1 or SW2, the Green or Blue LED will toggle three times. main program toggles Red LED while waiting for interrupt from SW1 or SW2.
  
 
=== 3. Interrupt from External Source ===
 
=== 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)
+
* 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)
*: Configure PORTD6 to trigger interrupt by falling edge. In the interrupt handler, the green LED (PF3) is toggled. The green LED should have half the frequency of the input signal at PORTD6. IRQ3 is assigned to PORTD6.
+
*:'''Hint''': Configure PORTD6 to trigger interrupt by falling edge. In the interrupt handler, the green LED (PF3) is toggled. The green LED should have half the frequency of the input signal at PORTD6. IRQ3 is assigned to PORTD6.
 
<!--
 
<!--
 
=== 4. UART0 Interrupt Programming to receive data ===
 
=== 4. UART0 Interrupt Programming to receive data ===
Line 25: Line 24:
 
-->
 
-->
  
 +
== See Also ==
 +
# [[EmSys:Tiva C Series TM4C123GXL Board | EK-TM4C123GXL LaunchPad Board]]
 +
# [[EmSys:Programming the GPIO in TM4C123 | GPIO Programming]]
  
  
  
 +
<!--
 
[[File:prev.gif|left|link=EmSys:TM4C123 GPIO Port Interrupt Programming]]
 
[[File:prev.gif|left|link=EmSys:TM4C123 GPIO Port Interrupt Programming]]
 
[[File:home.gif|center|link=EmSys:Interrupts in TM4C123GH6PM Launchpad]]
 
[[File:home.gif|center|link=EmSys:Interrupts in TM4C123GH6PM Launchpad]]
 +
-->

Latest revision as of 04:46, 3 March 2020

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 PortF 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. GPIOF interrupt from SW1 and SW2

  • Rewrite sw1_int.c program to distinguish the interrupt pin. Toggle Red LED on PF1 continuously. Upon pressing either SW1 or SW2, the Green or Blue LED will toggle three times. main program toggles Red LED while waiting for interrupt from SW1 or SW2.

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)
    Hint: Configure PORTD6 to trigger interrupt by falling edge. In the interrupt handler, the green LED (PF3) is toggled. The green LED should have half the frequency of the input signal at PORTD6. IRQ3 is assigned to PORTD6.

See Also

  1. EK-TM4C123GXL LaunchPad Board
  2. GPIO Programming