Interrupt with TMS320F2806

Discussion in 'Embedded Systems and Microcontrollers' started by DennisM, May 30, 2011.

  1. DennisM

    Thread Starter New Member

    May 17, 2011
    3
    0
    Hello everyone, I have some problems with the initialization of the interrupts. I have used the example code provided by the TI, unfortunatelly I am still not able generate any interrupts. Following code was applied,

    [c]
    Code ( (Unknown Language)):
    1. void DeviceInit(void)
    2. {
    3.     WDogDisable();     // Disable the watchdog initially
    4.     DINT;            // Global Disable all Interrupts
    5.     IER = 0x0000;    // Disable CPU interrupts
    6.     IFR = 0x0000;    // Clear all CPU interrupt flags
    7.  
    8. // SYSTEM CLOCK speed based on Crystal = 20 MHz
    9. // 0xA =  100    MHz        (10)
    10. // 0x9 =  90    MHz        (9)
    11. // 0x8 =  80    MHz        (8)
    12. // 0x7 =  70    MHz        (7)
    13. // 0x6 =  60    MHz        (6)
    14. // 0x5 =  50    MHz        (5)
    15. // 0x4 =  40    MHz        (4)
    16. // 0x3 =  30    MHz        (3)
    17. // 0x2 =  20    MHz        (2)
    18.  
    19.     PLLset(0xA);    // choose from options above
    20.  
    21. // Initialise interrupt controller and Vector Table
    22. // to defaults for now. Application ISR mapping done later.
    23.     PieCntlInit();        
    24.     PieVectTableInit();
    25.  
    26.    EALLOW; // below registers are "protected", allow access.
    27.  
    28. // HIGH / LOW SPEED CLOCKS prescale register settings
    29.    SysCtrlRegs.HISPCP.all = 0x0002;        // Sysclk / 4 (25 MHz)
    30.    SysCtrlRegs.LOSPCP.all = 0x0002;        // Sysclk / 4 (25 MHz)
    31.    SysCtrlRegs.XCLK.bit.XCLKOUTDIV=2;
    32.          
    33. // PERIPHERAL CLOCK ENABLES
    34. //---------------------------------------------------
    35. // If you are not using a peripheral you may want to switch
    36. // the clock off to save power, i.e. set to =0
    37. //
    38. // Note: not all peripherals are available on all 280x derivates.
    39. // Refer to the datasheet for your particular device.
    40.  
    41.    SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;    // ADC
    42.    //------------------------------------------------
    43.    SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 0;   // I2C
    44.    //------------------------------------------------
    45.    SysCtrlRegs.PCLKCR0.bit.SPIAENCLK=0;     // SPI-A
    46.    SysCtrlRegs.PCLKCR0.bit.SPIBENCLK=0;     // SPI-B
    47.    SysCtrlRegs.PCLKCR0.bit.SPICENCLK=0;     // SPI-C
    48. .
    49. .
    50. .
    51.     GpioDataRegs.GPBSET.bit.GPIO34 = 1;        // uncomment if --> Set High initially
    52. //--------------------------------------------------------------------------------------
    53.     EDIS;    // Disable register access
    54. }
    [/c]

    [c]
    Code ( (Unknown Language)):
    1. // This function initializes the PIE control registers to a known state.
    2. //
    3. void PieCntlInit(void)
    4. {
    5.     // Disable Interrupts at the CPU level:
    6.     DINT;
    7.  
    8.     // Disable the PIE
    9.     PieCtrlRegs.PIECTRL.bit.ENPIE = 0;
    10.  
    11.     // Clear all PIEIER registers:
    12.     PieCtrlRegs.PIEIER1.all = 0;
    13.     PieCtrlRegs.PIEIER2.all = 0;
    14.     PieCtrlRegs.PIEIER3.all = 0;    
    15.     PieCtrlRegs.PIEIER4.all = 0;
    16.     PieCtrlRegs.PIEIER5.all = 0;
    17.     PieCtrlRegs.PIEIER6.all = 0;
    18.     PieCtrlRegs.PIEIER7.all = 0;
    19.     PieCtrlRegs.PIEIER8.all = 0;
    20.     PieCtrlRegs.PIEIER9.all = 0;
    21.     PieCtrlRegs.PIEIER10.all = 0;
    22.     PieCtrlRegs.PIEIER11.all = 0;
    23.     PieCtrlRegs.PIEIER12.all = 0;
    24.  
    25.     // Clear all PIEIFR registers:
    26.     PieCtrlRegs.PIEIFR1.all = 0;
    27.     PieCtrlRegs.PIEIFR2.all = 0;
    28.     PieCtrlRegs.PIEIFR3.all = 0;    
    29.     PieCtrlRegs.PIEIFR4.all = 0;
    30.     PieCtrlRegs.PIEIFR5.all = 0;
    31.     PieCtrlRegs.PIEIFR6.all = 0;
    32.     PieCtrlRegs.PIEIFR7.all = 0;
    33.     PieCtrlRegs.PIEIFR8.all = 0;
    34.     PieCtrlRegs.PIEIFR9.all = 0;
    35.     PieCtrlRegs.PIEIFR10.all = 0;
    36.     PieCtrlRegs.PIEIFR11.all = 0;
    37.     PieCtrlRegs.PIEIFR12.all = 0;
    38. }    
    39.  
    40.  
    41. void PieVectTableInit(void)
    42. {
    43.     int16    i;
    44.     Uint32 *Source = (void *) &ISR_ILLEGAL;
    45.     Uint32 *Dest = (void *) &PieVectTable;
    46.        
    47.     EALLOW;    
    48.     for(i=0; i < 128; i++)
    49.         *Dest++ = *Source;    
    50.     EDIS;
    51.  
    52.     // Enable the PIE Vector Table
    53.     PieCtrlRegs.PIECTRL.bit.ENPIE = 1;    
    54. }
    55.  
    56. interrupt void ISR_ILLEGAL(void)   // Illegal operation TRAP
    57. {
    58.   // Insert ISR Code here
    59.  
    60.   // Next two lines for debug only to halt the processor here
    61.   // Remove after inserting ISR Code
    62.   asm("          ESTOP0");
    63.   for(;;);
    64.  
    65. }
    [/c]



    this is the code I have used for the implementation, when I am setting an LED in the interrupt function high, it doesnt work.

    Does anyone has any ideas.

    Thx
     
  2. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    Well it's been a while since I have worked on a TI chip... i have been in freescale and PIC land lately....

    But, I see several 'global interrupt disable' commands and no enable commands! Actually, I don't even see any ISR where you are toggling a register to flash an LED!

    Have you been able to flash an LED without interrupts yet?
     
Loading...