大家好!我现在用TMS320F28035做一个电源的控制,其中CLA处理闭环程序,由ADC触发,ADC采样由EPWM触发,这些调试中都没问题。现在想加一个Timer0的1kHz中断用来做定时,但是调试中发现使能PieCtrlRegs.PIEIER1.bit.INTx7 = 1之后(下面程序中标***部分),程序一运行就停止,且显示“No source available for "0x3ff599" ”,再运行还是马上停止显示同样的内容,我查了一下0x3ff599是属于Boot ROM。如果把使能中断那一行屏蔽掉,则运行正常(不产生Timer0中断)。我试过其他的中断,比如让CPU处理一个ADC中断,也会发生同样的问题。请问这是什么原因呢?
main()的内容为:
DeviceInit(); // Device Life support & GPIO
memcpy((Uint16 *)&RamfuncsRunStart,(Uint16 *)&RamfuncsLoadStart, (unsigned long)&RamfuncsLoadSize);
InitFlash();
CLA_Init();
InitEPwmGpio();
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 60, 50000);
CpuTimer0Regs.PRD.all = mSec0_5;
EPWM_CNF();
DPL_CLAInit(); // Digital Power (DP) library initialization
// INTERRUPT & ISR INITIALISATION
PieVectTable.TINT0 = &TimerIsr0; // 1 KHz ISR from CPU Timer 2
PieVectTable.EPWM1_TZINT = &EpwmTZ1;
EALLOW;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // PIE level enable, Grp1 / Int7 TINT0*******************
PieCtrlRegs.PIEIER2.bit.INTx1 = 1; // PIE level enable, Grp2 / Int1 EPWM1_TZINT
EDIS;
IER |= M_INT1|M_INT2; // Enable CPU INT1&2 connected to EPWM1-6 INTs:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
// Background Loop
for (;;);
Timer0中断处理程序为:
#pragma CODE_SECTION(TimerIsr0,"ramfuncs");
__interrupt void TimerIsr0(void) // 2kHz
{
Counter_500us++;
if (Counter_500us > 9)
Counter_5ms++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
Brian Wang0:
考虑一下PIE有没有正确初始化?
大家好!我现在用TMS320F28035做一个电源的控制,其中CLA处理闭环程序,由ADC触发,ADC采样由EPWM触发,这些调试中都没问题。现在想加一个Timer0的1kHz中断用来做定时,但是调试中发现使能PieCtrlRegs.PIEIER1.bit.INTx7 = 1之后(下面程序中标***部分),程序一运行就停止,且显示“No source available for "0x3ff599" ”,再运行还是马上停止显示同样的内容,我查了一下0x3ff599是属于Boot ROM。如果把使能中断那一行屏蔽掉,则运行正常(不产生Timer0中断)。我试过其他的中断,比如让CPU处理一个ADC中断,也会发生同样的问题。请问这是什么原因呢?
main()的内容为:
DeviceInit(); // Device Life support & GPIO
memcpy((Uint16 *)&RamfuncsRunStart,(Uint16 *)&RamfuncsLoadStart, (unsigned long)&RamfuncsLoadSize);
InitFlash();
CLA_Init();
InitEPwmGpio();
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 60, 50000);
CpuTimer0Regs.PRD.all = mSec0_5;
EPWM_CNF();
DPL_CLAInit(); // Digital Power (DP) library initialization
// INTERRUPT & ISR INITIALISATION
PieVectTable.TINT0 = &TimerIsr0; // 1 KHz ISR from CPU Timer 2
PieVectTable.EPWM1_TZINT = &EpwmTZ1;
EALLOW;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // PIE level enable, Grp1 / Int7 TINT0*******************
PieCtrlRegs.PIEIER2.bit.INTx1 = 1; // PIE level enable, Grp2 / Int1 EPWM1_TZINT
EDIS;
IER |= M_INT1|M_INT2; // Enable CPU INT1&2 connected to EPWM1-6 INTs:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
// Background Loop
for (;;);
Timer0中断处理程序为:
#pragma CODE_SECTION(TimerIsr0,"ramfuncs");
__interrupt void TimerIsr0(void) // 2kHz
{
Counter_500us++;
if (Counter_500us > 9)
Counter_5ms++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
Guoen Cao:
回复 Brian Wang0:
谢谢您的回复。应该不是PIE的配置问题,因为我把CLA相关的程序注释掉后,Timer0的中断就很正常。请问还可能是什么原因呢?
下面是系统初始化的部分程序:
void DeviceInit(void){ WDogDisable(); // Disable the watchdog initially DINT; // Global Disable all Interrupts IER = 0x0000; // Disable CPU interrupts IFR = 0x0000; // Clear all CPU interrupt flags
// Switch to Internal Oscillator 1 and turn off all other clock// sources to minimize power consumption EALLOW; SysCtrlRegs.CLKCTL.bit.INTOSC1OFF = 0; SysCtrlRegs.CLKCTL.bit.OSCCLKSRCSEL=0; // Clk Src = INTOSC1 SysCtrlRegs.CLKCTL.bit.XCLKINOFF=1; // Turn off XCLKIN SysCtrlRegs.CLKCTL.bit.XTALOSCOFF=1; // Turn off XTALOSC SysCtrlRegs.CLKCTL.bit.INTOSC2OFF=1; // Turn off INTOSC2 EDIS;
// SYSTEM CLOCK speed based on internal oscillator = 10 MHz// 0xC = 60 MHz (12)// 0xB = 55 MHz (11)// 0xA = 50 MHz (10)// 0x9 = 45 MHz (9)// 0x8 = 40 MHz (8)// 0x7 = 35 MHz (7)// 0x6 = 30 MHz (6)// 0x5 = 25 MHz (5)// 0x4 = 20 MHz (4)// 0x3 = 15 MHz (3)// 0x2 = 10 MHz (2)
PLLset(0xC); // choose from options above
// Initialise interrupt controller and Vector Table// to defaults for now. Application ISR mapping done later. PieCntlInit(); PieVectTableInit();
EALLOW; // below registers are "protected", allow access.
// LOW SPEED CLOCKS prescale register settings SysCtrlRegs.LOSPCP.all = 0x0002; // Sysclk / 4 (15 MHz) SysCtrlRegs.XCLK.bit.XCLKOUTDIV=2;
// ADC CALIBRATION//—————————————————// The Device_cal function, which copies the ADC & oscillator calibration values// from TI reserved OTP into the appropriate trim registers, occurs automatically// in the Boot ROM. If the boot ROM code is bypassed during the debug process, the// following function MUST be called for the ADC and oscillators to function according// to specification.
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // Enable ADC peripheral clock (*Device_cal)(); // Auto-calibrate from TI OTP SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 0; // Return ADC clock to original state
// PERIPHERAL CLOCK ENABLES//—————————————————// If you are not using a peripheral you may want to switch// the clock off to save power, i.e. set to =0//// Note: not all peripherals are available on all 280x derivates.// Refer to the datasheet for your particular device.
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // ADC //———————————————— SysCtrlRegs.PCLKCR3.bit.COMP1ENCLK = 1; // COMP1 SysCtrlRegs.PCLKCR3.bit.COMP2ENCLK = 1; // COMP2 SysCtrlRegs.PCLKCR3.bit.COMP3ENCLK = 1; // COMP3 //———————————————— SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK = 0; //eCAP1 //———————————————— SysCtrlRegs.PCLKCR0.bit.ECANAENCLK=0; // eCAN-A //———————————————— SysCtrlRegs.PCLKCR1.bit.EQEP1ENCLK = 0; // eQEP1 //———————————————— SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // ePWM1 SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1; // ePWM2 SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1; // ePWM3 SysCtrlRegs.PCLKCR1.bit.EPWM4ENCLK = 1; // ePWM4 SysCtrlRegs.PCLKCR1.bit.EPWM5ENCLK = 1; // ePWM5 SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 1; // ePWM6 SysCtrlRegs.PCLKCR1.bit.EPWM7ENCLK = 0; // ePWM7 SysCtrlRegs.PCLKCR0.bit.HRPWMENCLK = 0; // HRPWM //———————————————— SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1; // I2C //———————————————— SysCtrlRegs.PCLKCR0.bit.LINAENCLK = 0; // LIN-A //———————————————— SysCtrlRegs.PCLKCR3.bit.CLA1ENCLK = 1; // CLA1 //———————————————— SysCtrlRegs.PCLKCR0.bit.SCIAENCLK = 1; // SCI-A //———————————————— SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 0; // SPI-A SysCtrlRegs.PCLKCR0.bit.SPIBENCLK = 0; // SPI-B //———————————————— SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Enable TBCLK //————————————————
//————————————————————————————–// GPIO (GENERAL PURPOSE I/O) CONFIG//————————————————————————————–//———————–// QUICK NOTES on USAGE://———————–// If GpioCtrlRegs.GP?MUX?bit.GPIO?= 1, 2 or 3 (i.e. Non GPIO func), then leave// rest of lines commented// If GpioCtrlRegs.GP?MUX?bit.GPIO?= 0 (i.e. GPIO func), then:// 1) uncomment GpioCtrlRegs.GP?DIR.bit.GPIO? = ? and choose pin to be IN or OUT// 2) If IN, can leave next to lines commented// 3) If OUT, uncomment line with ..GPACLEAR.. to force pin LOW or// uncomment line with ..GPASET.. to force pin HIGH or//————————————————————————————–//————————————————————————————–// GPIO-00 – PIN FUNCTION = SEPIC-PWM GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // 0=GPIO, 1=EPWM1A, 2=Resv, 3=Resv// GpioCtrlRegs.GPADIR.bit.GPIO0 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO0 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO0 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-01 – PIN FUNCTION = PWM 1B GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // 0=GPIO, 1=EPWM1B, 2=Resv, 3=COMP1OUT GpioCtrlRegs.GPADIR.bit.GPIO1 = 1; // 1=OUTput, 0=INput GpioDataRegs.GPACLEAR.bit.GPIO1 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO1 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-02 – PIN FUNCTION = LED String 1 PWM GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0; // 0=GPIO, 1=EPWM2A, 2=Resv, 3=Resv GpioCtrlRegs.GPADIR.bit.GPIO2 = 1; // 1=OUTput, 0=INput GpioDataRegs.GPACLEAR.bit.GPIO2 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO2 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-03 – PIN FUNCTION = LED String 2 PWM GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 1; // 0=GPIO, 1=EPWM2B, 2=SPISOMI-A, 3=COMP2OUT// GpioCtrlRegs.GPADIR.bit.GPIO3 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO3 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO3 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-04 – PIN FUNCTION = LED String 3 PWM GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1; // 0=GPIO, 1=EPWM3A, 2=Resv, 3=Resv// GpioCtrlRegs.GPADIR.bit.GPIO4 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO4 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO4 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-05 – PIN FUNCTION = LED String 4 PWM GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1; // 0=GPIO, 1=EPWM3B, 2=SPISIMO-A, 3=ECAP1// GpioCtrlRegs.GPADIR.bit.GPIO5 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO5 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO5 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-06 – PIN FUNCTION = LED String 5 PWM GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1; // 0=GPIO, 1=EPWM4A, 2=SYNCI, 3=SYNCO// GpioCtrlRegs.GPADIR.bit.GPIO6 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO6 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO6 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-07 – PIN FUNCTION = LED String 6 PWM GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 1; // 0=GPIO, 1=EPWM4B, 2=SCIRX-A, 3=Resv// GpioCtrlRegs.GPADIR.bit.GPIO7 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO7 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO7 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-08 – PIN FUNCTION = LED String 7 PWM GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 1; // 0=GPIO, 1=EPWM5A, 2=Resv, 3=ADCSOC-A// GpioCtrlRegs.GPADIR.bit.GPIO8 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO8 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO8 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-09 – PIN FUNCTION = LED String 8 PWM GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 1; // 0=GPIO, 1=EPWM5B, 2=LINTX-A, 3=Resv// GpioCtrlRegs.GPADIR.bit.GPIO9 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO9 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO9 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-10 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 0; // 0=GPIO, 1=EPWM6A, 2=Resv, 3=ADCSOC-B GpioCtrlRegs.GPADIR.bit.GPIO10 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO10 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO10 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-11 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 0; // 0=GPIO, 1=EPWM6B, 2=LINRX-A, 3=Resv GpioCtrlRegs.GPADIR.bit.GPIO11 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO11 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO11 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-12 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0; // 0=GPIO, 1=TZ1, 2=SCITX-A, 3=SPISIMO-B GpioCtrlRegs.GPADIR.bit.GPIO12 = 1; // 1=OUTput, 0=INput GpioDataRegs.GPACLEAR.bit.GPIO12 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO12 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-13 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 0; // 0=GPIO, 1=TZ2, 2=Resv, 3=SPISOMI-B GpioCtrlRegs.GPADIR.bit.GPIO13 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO13 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO13 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-14 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 0; // 0=GPIO, 1=TZ3, 2=LINTX-A, 3=SPICLK-B GpioCtrlRegs.GPADIR.bit.GPIO14 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO14 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO14 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-15 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 0; // 0=GPIO, 1=TZ1, 2=LINRX-A, 3=SPISTE-B GpioCtrlRegs.GPADIR.bit.GPIO15 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO15 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO15 = 1; // uncomment if –> Set High initially//————————————————————————————–//————————————————————————————–// GPIO-16 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 0; // 0=GPIO, 1=SPISIMO-A, 2=Resv, 3=TZ2 GpioCtrlRegs.GPADIR.bit.GPIO16 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO16 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO16 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-17 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 0; // 0=GPIO, 1=SPISOMI-A, 2=Resv, 3=TZ3 GpioCtrlRegs.GPADIR.bit.GPIO17 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO17 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO17 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-18 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 0; // 0=GPIO, 1=SPICLK-A, 2=LINTX-A, 3=XCLKOUT GpioCtrlRegs.GPADIR.bit.GPIO18 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO18 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO18 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-19 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 0; // 0=GPIO, 1=SPISTE-A, 2=LINRX-A, 3=ECAP1 GpioCtrlRegs.GPADIR.bit.GPIO19 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO19 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO19 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-20 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 0; // 0=GPIO, 1=EQEPA-1, 2=Resv, 3=COMP1OUT GpioCtrlRegs.GPADIR.bit.GPIO20 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO20 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO20 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-21 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 0; // 0=GPIO, 1=EQEPB-1, 2=Resv, 3=COMP2OUT GpioCtrlRegs.GPADIR.bit.GPIO21 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO21 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO21 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-22 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 0; // 0=GPIO, 1=EQEPS-1, 2=Resv, 3=LINTX-A GpioCtrlRegs.GPADIR.bit.GPIO22 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO22 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO22 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-23 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 0; // 0=GPIO, 1=EQEPI-1, 2=Resv, 3=LINRX-A GpioCtrlRegs.GPADIR.bit.GPIO23 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO23 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO23 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-24 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 0; // 0=GPIO, 1=ECAP1, 2=Resv, 3=SPISIMO-B GpioCtrlRegs.GPADIR.bit.GPIO24 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO24 = 1; // uncomment if –> Set Low initially GpioDataRegs.GPASET.bit.GPIO24 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-25 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 0; // 0=GPIO, 1=Resv, 2=Resv, 3=SPISOMI-B GpioCtrlRegs.GPADIR.bit.GPIO25 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO25 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO25 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-26 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 0; // 0=GPIO, 1=Resv, 2=Resv, 3=SPICLK-B GpioCtrlRegs.GPADIR.bit.GPIO26 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO26 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO26 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-27 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 0; // 0=GPIO, 1=Resv, 2=Resv, 3=SPISTE-B GpioCtrlRegs.GPADIR.bit.GPIO27 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO27 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO27 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-28 – PIN FUNCTION = SCI-RX GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; // 0=GPIO, 1=SCIRX-A, 2=I2CSDA-A, 3=TZ2// GpioCtrlRegs.GPADIR.bit.GPIO28 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO28 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO28 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-29 – PIN FUNCTION = SCI-TX GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; // 0=GPIO, 1=SCITXD-A, 2=I2CSCL-A, 3=TZ3// GpioCtrlRegs.GPADIR.bit.GPIO29 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO29 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO29 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-30 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 0; // 0=GPIO, 1=CANRX-A, 2=Resv, 3=Resv GpioCtrlRegs.GPADIR.bit.GPIO30 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO30 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPASET.bit.GPIO30 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-31 – PIN FUNCTION = LED2 on controlCARD GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 0; // 0=GPIO, 1=CANTX-A, 2=Resv, 3=Resv GpioCtrlRegs.GPADIR.bit.GPIO31 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPACLEAR.bit.GPIO31 = 1; // uncomment if –> Set Low initially GpioDataRegs.GPASET.bit.GPIO31 = 1; // uncomment if –> Set High initially//————————————————————————————–//————————————————————————————–// GPIO-32 – PIN FUNCTION = I2CSDA GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // 0=GPIO, 1=I2CSDA-A, 2=SYNCI, 3=ADCSOCA// GpioCtrlRegs.GPBDIR.bit.GPIO32 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO32 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPBSET.bit.GPIO32 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-33 – PIN FUNCTION = PFC-DrvEnable GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // 0=GPIO, 1=I2CSCL-A, 2=SYNCO, 3=ADCSOCB// GpioCtrlRegs.GPBDIR.bit.GPIO33 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO33 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPBSET.bit.GPIO33 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-34 – PIN FUNCTION = LED3 on controlCARD GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; // 0=GPIO, 1=Resv, 2=Resv, 3=Resv GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO34 = 1; // uncomment if –> Set Low initially GpioDataRegs.GPBSET.bit.GPIO34 = 1; // uncomment if –> Set High initially//————————————————————————————–//————————————————————————————–// GPIO 35-38 are defaulted to JTAG usage, and are not shown here to enforce JTAG debug// usage.//————————————————————————————–//————————————————————————————–// GPIO-39 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPBMUX1.bit.GPIO39 = 0; // 0=GPIO, 1=Resv, 2=Resv, 3=Resv GpioCtrlRegs.GPBDIR.bit.GPIO39 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO39 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPBSET.bit.GPIO39 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-40 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPBMUX1.bit.GPIO40 = 0; // 0=GPIO, 1=EPWM7A, 2=Resv, 3=Resv GpioCtrlRegs.GPBDIR.bit.GPIO40 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO40 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPBSET.bit.GPIO40 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-41 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPBMUX1.bit.GPIO41 = 0; // 0=GPIO, 1=EPWM7B, 2=Resv, 3=Resv GpioCtrlRegs.GPBDIR.bit.GPIO41 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO41 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPBSET.bit.GPIO41 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-42 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPBMUX1.bit.GPIO42 = 0; // 0=GPIO, 1=Resv, 2=Resv, 3=COMP1OUT GpioCtrlRegs.GPBDIR.bit.GPIO42 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO42 = 1; // uncomment if –> Set Low initially GpioDataRegs.GPBSET.bit.GPIO42 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-43 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPBMUX1.bit.GPIO43 = 0; // 0=GPIO, 1=Resv, 2=Resv, 3=COMP2OUT GpioCtrlRegs.GPBDIR.bit.GPIO43 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO43 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPBSET.bit.GPIO43 = 1; // uncomment if –> Set High initially//————————————————————————————–// GPIO-44 – PIN FUNCTION = –Spare– GpioCtrlRegs.GPBMUX1.bit.GPIO44 = 0; // 0=GPIO, 1=Resv, 2=Resv, 3=Resv GpioCtrlRegs.GPBDIR.bit.GPIO44 = 0; // 1=OUTput, 0=INput// GpioDataRegs.GPBCLEAR.bit.GPIO44 = 1; // uncomment if –> Set Low initially// GpioDataRegs.GPBSET.bit.GPIO44 = 1; // uncomment if –> Set High initially//————————————————————————————–//————————————————————————————– EDIS; // Disable register access}
void PieCntlInit(void){ // Disable Interrupts at the CPU level: DINT;
// Disable the PIE PieCtrlRegs.PIECTRL.bit.ENPIE = 0;
// Clear all PIEIER registers: PieCtrlRegs.PIEIER1.all = 0; PieCtrlRegs.PIEIER2.all = 0; PieCtrlRegs.PIEIER3.all = 0; PieCtrlRegs.PIEIER4.all = 0; PieCtrlRegs.PIEIER5.all = 0; PieCtrlRegs.PIEIER6.all = 0; PieCtrlRegs.PIEIER7.all = 0; PieCtrlRegs.PIEIER8.all = 0; PieCtrlRegs.PIEIER9.all = 0; PieCtrlRegs.PIEIER10.all = 0; PieCtrlRegs.PIEIER11.all = 0; PieCtrlRegs.PIEIER12.all = 0;
// Clear all PIEIFR registers: PieCtrlRegs.PIEIFR1.all = 0; PieCtrlRegs.PIEIFR2.all = 0; PieCtrlRegs.PIEIFR3.all = 0; PieCtrlRegs.PIEIFR4.all = 0; PieCtrlRegs.PIEIFR5.all = 0; PieCtrlRegs.PIEIFR6.all = 0; PieCtrlRegs.PIEIFR7.all = 0; PieCtrlRegs.PIEIFR8.all = 0; PieCtrlRegs.PIEIFR9.all = 0; PieCtrlRegs.PIEIFR10.all = 0; PieCtrlRegs.PIEIFR11.all = 0; PieCtrlRegs.PIEIFR12.all = 0;}
void PieVectTableInit(void){ int16 i; Uint32 *Source = (void *) &ISR_ILLEGAL; Uint32 *Dest = (void *) &PieVectTable;
EALLOW; for(i=0; i < 128; i++) *Dest++ = *Source; EDIS;
// Enable the PIE Vector Table PieCtrlRegs.PIECTRL.bit.ENPIE = 1;}
大家好!我现在用TMS320F28035做一个电源的控制,其中CLA处理闭环程序,由ADC触发,ADC采样由EPWM触发,这些调试中都没问题。现在想加一个Timer0的1kHz中断用来做定时,但是调试中发现使能PieCtrlRegs.PIEIER1.bit.INTx7 = 1之后(下面程序中标***部分),程序一运行就停止,且显示“No source available for "0x3ff599" ”,再运行还是马上停止显示同样的内容,我查了一下0x3ff599是属于Boot ROM。如果把使能中断那一行屏蔽掉,则运行正常(不产生Timer0中断)。我试过其他的中断,比如让CPU处理一个ADC中断,也会发生同样的问题。请问这是什么原因呢?
main()的内容为:
DeviceInit(); // Device Life support & GPIO
memcpy((Uint16 *)&RamfuncsRunStart,(Uint16 *)&RamfuncsLoadStart, (unsigned long)&RamfuncsLoadSize);
InitFlash();
CLA_Init();
InitEPwmGpio();
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 60, 50000);
CpuTimer0Regs.PRD.all = mSec0_5;
EPWM_CNF();
DPL_CLAInit(); // Digital Power (DP) library initialization
// INTERRUPT & ISR INITIALISATION
PieVectTable.TINT0 = &TimerIsr0; // 1 KHz ISR from CPU Timer 2
PieVectTable.EPWM1_TZINT = &EpwmTZ1;
EALLOW;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // PIE level enable, Grp1 / Int7 TINT0*******************
PieCtrlRegs.PIEIER2.bit.INTx1 = 1; // PIE level enable, Grp2 / Int1 EPWM1_TZINT
EDIS;
IER |= M_INT1|M_INT2; // Enable CPU INT1&2 connected to EPWM1-6 INTs:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
// Background Loop
for (;;);
Timer0中断处理程序为:
#pragma CODE_SECTION(TimerIsr0,"ramfuncs");
__interrupt void TimerIsr0(void) // 2kHz
{
Counter_500us++;
if (Counter_500us > 9)
Counter_5ms++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
Guoen Cao:
回复 Brian Wang0:
大神帮忙看看可能是什么原因啊?
大家好!我现在用TMS320F28035做一个电源的控制,其中CLA处理闭环程序,由ADC触发,ADC采样由EPWM触发,这些调试中都没问题。现在想加一个Timer0的1kHz中断用来做定时,但是调试中发现使能PieCtrlRegs.PIEIER1.bit.INTx7 = 1之后(下面程序中标***部分),程序一运行就停止,且显示“No source available for "0x3ff599" ”,再运行还是马上停止显示同样的内容,我查了一下0x3ff599是属于Boot ROM。如果把使能中断那一行屏蔽掉,则运行正常(不产生Timer0中断)。我试过其他的中断,比如让CPU处理一个ADC中断,也会发生同样的问题。请问这是什么原因呢?
main()的内容为:
DeviceInit(); // Device Life support & GPIO
memcpy((Uint16 *)&RamfuncsRunStart,(Uint16 *)&RamfuncsLoadStart, (unsigned long)&RamfuncsLoadSize);
InitFlash();
CLA_Init();
InitEPwmGpio();
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 60, 50000);
CpuTimer0Regs.PRD.all = mSec0_5;
EPWM_CNF();
DPL_CLAInit(); // Digital Power (DP) library initialization
// INTERRUPT & ISR INITIALISATION
PieVectTable.TINT0 = &TimerIsr0; // 1 KHz ISR from CPU Timer 2
PieVectTable.EPWM1_TZINT = &EpwmTZ1;
EALLOW;
PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // PIE level enable, Grp1 / Int7 TINT0*******************
PieCtrlRegs.PIEIER2.bit.INTx1 = 1; // PIE level enable, Grp2 / Int1 EPWM1_TZINT
EDIS;
IER |= M_INT1|M_INT2; // Enable CPU INT1&2 connected to EPWM1-6 INTs:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
// Background Loop
for (;;);
Timer0中断处理程序为:
#pragma CODE_SECTION(TimerIsr0,"ramfuncs");
__interrupt void TimerIsr0(void) // 2kHz
{
Counter_500us++;
if (Counter_500us > 9)
Counter_5ms++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
Brian Wang0:
回复 Guoen Cao:
http://e2e.ti.com/support/microcontrollers/c2000/f/171/t/555405?tisearch=e2e-sitesearch&keymatch=interrupt%200x3ff599
参考一下这个帖子,看看有没有可能是存储空间分配以及使用权的问题