这是我正在用的初始化程序。你可以比较一下
void InitSci(void)
{
// Initialize SCI-A:
EALLOW;
GpioMuxRegsGPGMUXbitSCITXDB_GPIOG4 = 1;
GpioMuxRegsGPGMUXbitSCIRXDB_GPIOG5 = 1;
EDIS;
/ loopback 8 bit data /
ScibRegsSCICCRall = 0x07; // 1 bit stop, disable parity, idle mode, 8 bits data
ScibRegsSCICTL1all = 0x03; // enable TX
ScibRegsSCICTL2all = 0x03; //
ScibRegsSCIHBAUD = 0x00;
ScibRegsSCILBAUD = 0x61;//f3 19200 79 38400 150mhz
ScibRegsSCICTL1all = 0x23;//enable sci
PieCtrlPIEIER9bitINTx3 = 1;//scirxintb enable int
PieCtrlPIEIER9bitINTx4 = 1;//scitxintb
//tbd
// Initialize SCI-B:
//tbd
}
这是 DSP28335的例程,程序目的是通过按不同的按键,通过中断改变LED的闪动方式
,你可以对比一下。 (DSP2812和 DSP28335是差不多的)
#include "DSP2833x_Deviceh" // DSP2833x Headerfile Include File#include "DSP2833x_Examplesh" // DSP2833x Examples Include File
#define LED1_ON GpioDataRegsGPASETbitGPIO0=1
#define LED1_OFF GpioDataRegsGPACLEARbitGPIO0=1
#define LED2_ON GpioDataRegsGPASETbitGPIO1=1
#define LED2_OFF GpioDataRegsGPACLEARbitGPIO1=1
#define LED3_ON GpioDataRegsGPASETbitGPIO2=1
#define LED3_OFF GpioDataRegsGPACLEARbitGPIO2=1
#define LED4_ON GpioDataRegsGPASETbitGPIO3=1
#define LED4_OFF GpioDataRegsGPACLEARbitGPIO3=1
#define LED5_ON GpioDataRegsGPASETbitGPIO4=1
#define LED5_OFF GpioDataRegsGPACLEARbitGPIO4=1
#define LED6_ON GpioDataRegsGPASETbitGPIO5=1
#define LED6_OFF GpioDataRegsGPACLEARbitGPIO5=1
#define LED7_ON GpioDataRegsGPBSETbitGPIO51=1
#define LED7_OFF GpioDataRegsGPBCLEARbitGPIO51=1
#define LED8_ON GpioDataRegsGPBSETbitGPIO50=1
#define LED8_OFF GpioDataRegsGPBCLEARbitGPIO50=1
interrupt void ISRExint3(void);
interrupt void ISRExint4(void);
interrupt void ISRExint5(void);
interrupt void ISRExint6(void);
void configtestled(void);
Uint16 sign ;
void main(void)
{
// Step 1 Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrlc file
InitSysCtrl();
// Step 2 Initalize GPIO:
// This example function is found in the DSP2833x_Gpioc file and
// illustrates how to set the GPIO to it's default state
// InitGpio(); // Skipped for this example
InitXintf16Gpio(); //zq
// Step 3 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 DSP2833x_PieCtrlc 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 DSP2833x_DefaultIsrc
// This function is found in DSP2833x_PieVectc
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to// ISR functions found within this file
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTableXINT3 = &ISRExint3;
PieVectTableXINT4 = &ISRExint4;
PieVectTableXINT5 = &ISRExint5;
PieVectTableXINT6 = &ISRExint6;
EDIS; // This is needed to disable write to EALLOW protected registers
PieCtrlRegsPIECTRLbitENPIE = 1; // Enable the PIE block
PieCtrlRegsPIEIER12bitINTx1= 1;
PieCtrlRegsPIEIER12bitINTx2= 1;
PieCtrlRegsPIEIER12bitINTx3= 1;
PieCtrlRegsPIEIER12bitINTx4= 1;
IER |= M_INT12; // Enable CPU int1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
configtestled();
sign = 0;
while(1)
{
if(sign==0)
{ LED1_OFF;
LED2_OFF;
LED3_OFF;
LED4_OFF;
LED5_OFF;
LED6_OFF;
LED7_OFF;
LED8_OFF;
DELAY_US(50000);
LED1_ON;
DELAY_US(50000);
LED2_ON;
DELAY_US(50000);
LED3_ON;
DELAY_US(50000);
LED4_ON;
DELAY_US(50000);
LED5_ON;
DELAY_US(50000);
LED6_ON;
DELAY_US(50000);
LED7_ON;
DELAY_US(50000);
LED8_ON;
DELAY_US(50000); //NO XINT
}
if(sign==3)
{
LED1_OFF;
LED2_OFF;
LED3_OFF;
LED4_OFF;
LED5_OFF;
LED6_OFF;
LED7_OFF;
LED8_OFF;
DELAY_US(50000);
LED1_ON;
LED2_ON;
DELAY_US(50000);
LED3_ON;
LED4_ON;
DELAY_US(50000);
LED5_ON;
LED6_ON;
DELAY_US(50000);
LED7_ON;
LED8_ON;
DELAY_US(50000); // XINT3 COME
}
if(sign==4)
{ LED1_ON;
LED2_ON;
LED3_ON;
LED4_ON;
LED5_ON;
LED6_ON;
LED7_ON;
LED8_ON;
DELAY_US(50000);
LED1_OFF;
DELAY_US(50000);
LED2_OFF;
DELAY_US(50000);
LED3_OFF;
DELAY_US(50000);
LED4_OFF;
DELAY_US(50000);
LED5_OFF;
DELAY_US(50000);
LED6_OFF;
DELAY_US(50000);
LED7_OFF;
DELAY_US(50000);
LED8_OFF;
DELAY_US(50000); // XINT4 COME
}
if(sign==5)
{LED1_ON;
LED2_ON;
LED3_ON;
LED4_ON;
LED5_ON;
LED6_ON;
LED7_ON;
LED8_ON;
DELAY_US(50000);
LED1_OFF;
LED2_OFF;
DELAY_US(50000);
LED3_OFF;
LED4_OFF;
LED1_ON;
LED2_ON;
DELAY_US(50000);
LED5_OFF;
LED6_OFF;
LED3_ON;
LED4_ON;
DELAY_US(50000);
LED7_OFF;
LED8_OFF;
LED5_ON;
LED6_ON;
DELAY_US(50000); // XINT5 COME
}
if(sign==6)
{LED1_OFF;
LED2_ON;
LED3_OFF;
LED4_ON;
LED5_OFF;
LED6_ON;
LED7_OFF;
LED8_ON;
DELAY_US(50000);
LED1_ON;
LED2_OFF;
LED3_ON;
LED4_OFF;
LED5_ON;
LED6_OFF;
LED7_ON;
LED8_OFF;
DELAY_US(50000); // XINT5 COME
}
}
}
interrupt void ISRExint3(void)
{
PieCtrlRegsPIEACKall = PIEACK_GROUP12;
sign=3;
}
interrupt void ISRExint4(void)
{
PieCtrlRegsPIEACKall = PIEACK_GROUP12;
sign=4;
}
interrupt void ISRExint5(void)
{
PieCtrlRegsPIEACKall = PIEACK_GROUP12;
sign=5;
}
interrupt void ISRExint6(void)
{
PieCtrlRegsPIEACKall = PIEACK_GROUP12;
sign=6;
}
void configtestled(void)
{
EALLOW;
GpioCtrlRegsGPAMUX1bitGPIO0 = 0; // GPIO0 = GPIO0
GpioCtrlRegsGPADIRbitGPIO0 = 1;
GpioCtrlRegsGPAMUX1bitGPIO1 = 0; // GPIO1 = GPIO1
GpioCtrlRegsGPADIRbitGPIO1 = 1;
GpioCtrlRegsGPAMUX1bitGPIO2 = 0; // GPIO2 = GPIO2
GpioCtrlRegsGPADIRbitGPIO2 = 1;
GpioCtrlRegsGPAMUX1bitGPIO3 = 0; // GPIO3 = GPIO3
GpioCtrlRegsGPADIRbitGPIO3 = 1;
GpioCtrlRegsGPAMUX1bitGPIO4 = 0; // GPIO4 = GPIO4
GpioCtrlRegsGPADIRbitGPIO4 = 1;
GpioCtrlRegsGPAMUX1bitGPIO5 = 0; // GPIO5 = GPIO5
GpioCtrlRegsGPADIRbitGPIO5 = 1;
GpioCtrlRegsGPBMUX2bitGPIO51 = 0; // GPIO51 = GPIO51
GpioCtrlRegsGPBDIRbitGPIO51 = 1;
GpioCtrlRegsGPBPUDbitGPIO51=0;
GpioCtrlRegsGPBMUX2bitGPIO50 = 0; // GPIO50 = GPIO50
GpioCtrlRegsGPBDIRbitGPIO50 = 1;
GpioCtrlRegsGPBPUDbitGPIO50=0;
EDIS;
}
//===========================================================================
// No more
//===========================================================================
以上就是关于TMS320F2812关于串口中断(非诚勿扰)全部的内容,包括:TMS320F2812关于串口中断(非诚勿扰)、关于 DSP 2812 外部中断 XINT1 使用问题、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)