Overview

In this tutorial, we will look at TMS320 interrupts. Interrupts are useful in many cases where a process simply wants to continue performing its main function and other units (timers or external events) seek its attention when needed. In other words, the microcontroller does not need to monitor timers, serial communication, or external pins GPIO_32 and GPIO_67. Every time an event related to these units occurs, the microcontroller is notified with the help of interrupts.

What is an interrupt?

  1. An interrupt is an external or internal event to get the attention of the CPU. Once the controller detects the interrupt, it suspends the current task and performs a special service procedure known as Interrupt Service Routine (ISR).
  2. When the interrupt is triggered, the microcontroller performs the following steps
  3. First, it finishes the execution of the instruction and saves the address of the next instruction (PC) on the stack.
  4. It also saves internally the current status of all counties.
  5. It is moved to a fixed location in memory, called the interrupt vector table, which contains the ISR address. The microcontroller gets the ISR address from the interrupt vector table and jumps to it and starts executing the interrupt service subroutine until it reaches the last instruction in the subroutine which is RETI (return interrupt)
  6. When the RETI instruction is executed, the microcontroller returns to where it left off.
  7. First, get the program counter (PC) address from the stack by popping the top two bytes of the stack into the computer.
  8. Then it starts running from this address.

Bill of Materials

S.N.COMPONENTS NAMEDESCRIPTIONQUANTITY
1LAUNCHXL-F28379DLAUNCHXL-F28379D1https://www.evelta.com/launchxl-f28379d-c2000-delfino-mcus-f28379d-launchpad-development-kit/
2ButtonAD8232 ECG Sensor Kit1https://robu.in/product/momentary-tactile-push-button-module-dc-5v-switch/?gclid=Cj0KCQiAmeKQBhDvARIsAHJ7mF6P9vrp8wVPhu44AGN5vVKmpgZPhSXaIrw0GZlnMCifb4MMVoW6LgIaAm2-EALw_wcB
3Connecting WiresJumper Wires20https://www.amazon.in/dp/B074JB6SX8/ref=twister_B074J9NMB9?_encoding=UTF8&psc=1
4Breadboard1http://amazon.in/Electronicspices-Point-Solderless-Breadboard-Prototype/dp/B08YX57FJG/ref=asc_df_B08YX57FJG/?tag=googleshopdes-21&linkCode=df0&hvadid=396988870302&hvpos=&hvnetw=g&hvrand=5555375138870789824&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9302486&hvtargid=pla-1364897184161&psc=1&ext_vrnc=hi

Circuit diagram

Final code

/*
 * main.c
 *
 *  Created on: 26-Nov-2021
 *      Author: Devilal
 */




#include "stdio.h"
#include "string.h"
#include "stdlib.h"

#include "F28x_Project.h"
#include "F2837xD_device.h"
#include "F2837xD_Examples.h"

#include "device.h"
#include "driverlib.h"

#define Input_1 32
#define out_put 67 // out put


void GPIO_init();
__interrupt void gpioInterruptHandler(void);
void main(void)
{


    Device_init();
    Device_initGPIO();

    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    GPIO_init();

    GPIO_setInterruptType(GPIO_INT_XINT1, GPIO_INT_TYPE_FALLING_EDGE);
    GPIO_setInterruptPin(Input_1, GPIO_INT_XINT1);
    GPIO_enableInterrupt(GPIO_INT_XINT1);

    Interrupt_register(INT_XINT1, &gpioInterruptHandler);

    Interrupt_enable(INT_XINT1);
    Interrupt_enableMaster();

    while(1)
    {

    }
}


void PinMux_init()
{
    GPIO_setPinConfig(GPIO_32_GPIO32);
    GPIO_setPinConfig(GPIO_34_GPIO34);
}

void GPIO_init()
{
    EALLOW;

    GPIO_setPinConfig(Input_1);
    GPIO_setDirectionMode(Input_1, GPIO_DIR_MODE_IN);
    GPIO_setPadConfig(Input_1, GPIO_PIN_TYPE_PULLUP);  //  Pull-up enable for input
    GPIO_setMasterCore(Input_1, GPIO_CORE_CPU1);

    GPIO_setDirectionMode(out_put, GPIO_DIR_MODE_OUT);
    GPIO_setPadConfig(out_put, GPIO_PIN_TYPE_STD);
    GPIO_writePin(out_put, 1);
    GPIO_setMasterCore(out_put, GPIO_CORE_CPU1);
    GPIO_setQualificationMode(out_put, GPIO_QUAL_SYNC);

    EDIS;

}

__interrupt void gpioInterruptHandler(void)
{

    GPIO_togglePin(out_put);

    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}


By Admin

Leave a Reply

Your email address will not be published.

%d bloggers like this: