I am interfacing common cathode seven segment display with Tiva C series TM4C123GXL tiva launch pad to display interrupt priority number on it. When switch SW2 (GPIO PF_0) is pressed it will indicate 1 and SW1 (GPIO_PF_4) is pressed it will indicate 2 for 5 sec duration each. When there is no interrupt display will indicate 0. For this task i am using GPIO port C and D to interfaced seven segment display with launchpad. pin connection given below.
(PC4 = A, PC5 = B, PC6 = C, PC7 = D , PD0 = E, PD1 = F, PD=G)
I have written some lines of code for this. This code will generating interrupt on microcontroller but performing tail changing task. I have to assign priority in this operation. when i pressed SW1 it will display 2 instantly when i pressed SW1 display will change number from 2 to 1. After completion of 1 it will continue to display 2 and complete 5 sec display.
I have to assign such type of priority but not able to set this priority with IntPrioritySet. Is there any another way to set priority on GPIO port pins?
Thanking you
I have written this code for tail changing.
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
void switch_interrupt(void);
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF))
{}
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD))
{}
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOC))
{}
GPIOPinTypeGPIOOutput ( GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 );
GPIOPinTypeGPIOOutput ( GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 );
GPIOIntRegister(GPIO_PORTF_BASE, switch_interrupt);
HWREG(GPIO_PORTF_BASE + 0x520u) = 0x4C4F434Bu;
HWREG(GPIO_PORTF_BASE + 0x524u) = 0xFFu;
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, (GPIO_PIN_0 | GPIO_PIN_4));
GPIOPadConfigSet(GPIO_PORTF_BASE, (GPIO_PIN_0 | GPIO_PIN_4), GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOIntTypeSet(GPIO_PORTF_BASE, (GPIO_PIN_0 | GPIO_PIN_4), GPIO_FALLING_EDGE);
IntEnable(INT_GPIOF);
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_4);
IntMasterEnable();
while(1)
{
GPIOPinWrite ( GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 , 0XF0); //0
GPIOPinWrite ( GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 , 0X03);
SysCtlDelay (66666666);
}
}
void switch_interrupt()
{
uint32_t interrupt_status;
interrupt_status = GPIOIntStatus(GPIO_PORTF_BASE, 1u);
if(interrupt_status == GPIO_PIN_0)
{
GPIOPinWrite ( GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 , 0X60); //1
GPIOPinWrite ( GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, 0);
SysCtlDelay (66666666);
}
else if (interrupt_status == GPIO_PIN_4)
{
GPIOPinWrite ( GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 , 0XB0); //2
GPIOPinWrite ( GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, 0X05);
SysCtlDelay (66666666);
}
GPIOIntClear(GPIO_PORTF_BASE, interrupt_status);
}