Part Number:TMS320F28377S
Hey guys,
I'm currently working on a project with the Delfino and ran into a problem when testing interrupts. I have my code set up s.t. whenever GPIO pin 17 receives the HIGH levels of a square-wave input, GPIO pin 18 (an output) is toggled from 0 to 1. Here's my code below. I was also wondering if my function generator was setup correctly for this purpose. I have 3.2 Vpp for the square wave with a 1.5 V offset and a period of 30 us. In addition, I have a 4.7k pull-down resistor before the input.
#include <stdint.h> #include <stdbool.h> #include <stdio.h> #include <file.h> #include "F28x_Project.h" // DSP28x Headerfile #include "ti_ascii.h" #include "sci_io.h" //risky //#include "Device.h" //#include "F2837xD_Examples.h" //########################################################################### // Global variables used in the project before main function. Declare other // variables in this section of the code. //########################################################################### Uint16 *kittens; //global pointer kittens Uint16 bit = 3; //test bit initilized randomly Uint16 bit_done_flag = 0; //flag to say that interrupt taken //########################################################################### // Declare the service routines and functions //########################################################################### interrupt void xint1_isr(void); //interrupt void cpu_timer0_isr(void); // interrupt void isr1(void); // void program1(void); // void program2(void); //###################### Beginning of the main code ####################### //void main(void) void main() { // Initialize System Control: // PLL, WatchDog, enable Peripheral Clocks // This example function is found in the F2837xD_SysCtrl.c file. InitSysCtrl(); // Clear all interrupts and initialize PIE vector table: // Disable CPU interrupts DINT; // Initialize the PIE control registers to their default state. // The default state is all PIE interrupts disabled and flags // are cleared. // This function is found in the F2837xD_PieCtrl.c file. InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // This will populate the entire table, even if the interrupt // is not used in this example. This is useful for debug purposes. // The shell ISR routines are found in F2837xD_DefaultIsr.c. // This function is found in F2837xD_PieVect.c. InitPieVectTable(); // Enable global Interrupts and higher priority real-time debug events: // EINT; // Enable Global interrupt INTM //ERTM; // Enable Global realtime interrupt DBGM //########################################################################### // User specific code: Your code comes here. //########################################################################### EALLOW; PieVectTable.XINT1_INT = &xint1_isr; EDIS; EALLOW; GpioCtrlRegs.GPAQSEL2.bit.GPIO17=1; GpioCtrlRegs.GPACTRL.bit.QUALPRD2 = 200; //input GpioCtrlRegs.GPAGMUX2.bit.GPIO17 = 0; GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 0; // GPIO 46 GpioCtrlRegs.GPADIR.bit.GPIO17 = 0; // input //GpioCtrlRegs.GPAINV.bit.GPIO17 = 1; //output probe GpioCtrlRegs.GPAGMUX2.bit.GPIO18 = 0; GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 0; // GPIO 46 GpioCtrlRegs.GPADIR.bit.GPIO18 = 1; // ouput GpioDataRegs.GPASET.bit.GPIO18 = 0; GPIO_SetupXINT1Gpio(17); XintRegs.XINT1CR.bit.POLARITY = 0; XintRegs.XINT1CR.bit.ENABLE = 1; PieCtrlRegs.PIECTRL.bit.ENPIE = 1; PieCtrlRegs.PIEIER1.bit.INTx4 = 1; IER |= M_INT1; EDIS; EINT; for(;;){ DELAY_US(1); Uint16 a = GpioDataRegs.GPADAT.bit.GPIO18; } } //###################### Start of functions codes ############# //#################### Interrupt Service Routines ################# //interrupt void xint1_isr(&*kittens) //interrupt void xint1_isr() interrupt void xint1_isr(void) { EALLOW; *kittens = 0; DELAY_US(1000000); GpioDataRegs.GPATOGGLE.bit.GPIO18 = 1; /*//while(!GpioDataRegs.GPBDAT.bit.GPIO46){ //2/4 change while(!GpioDataRegs.GPBDAT.bit.GPIO46){ DELAY_US(1); *kittens ++; */ EDIS; bit_done_flag=1; //a simple flag to see if interrupt triggered PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; } /*interrupt void cpu_timer0_isr(void){ //CpuTimer0Regs.TCR.bit.TRB = 1; GpioDataRegs.GPBSET.bit.GPIO41 = 1; //DELAY_US(3000000); DELAY_US(1); GpioDataRegs.GPBCLEAR.bit.GPIO41 = 1; PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; //toggle } */