lindabell 发表于 2011-3-28 08:58:28

DSP 2812 串口方式怎么发生数据的(没辙了)

这个代码能一直接收到0xaa;问题在于我在主程序没有发送数据怎么就进入发生中断服务中了呢???
还有我把发送中断的 SciaRegs.SCITXBUF=0xaa;注释掉,并在主函数中加入这句;但是从串口一个没收到
这个还不和单片即一样吗???



#include "DSP281x_Device.h"   // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File
#include "stdio.h"
#define CPU_FREQ        150E6
#define LSPCLK_FREQCPU_FREQ/4
#define SCI_FREQ        9600//100E3      //波特率
#define SCI_PRD        ((LSPCLK_FREQ/(SCI_FREQ*8))-1)

// Prototype statements for functions found within this file.
interrupt void sciaTxFifoIsr(void);
interrupt void sciaRxFifoIsr(void);

void scia_fifo_init(void);

// Global variables


void main(void)
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();
// Setup only the GP I/O only for SCI-A and SCI-B functionality
   EALLOW;
   GpioMuxRegs.GPFMUX.bit.SCITXDA_GPIOF4 = 1;
   GpioMuxRegs.GPFMUX.bit.SCIRXDA_GPIOF5 = 1;
   GpioMuxRegs.GPGMUX.bit.SCITXDB_GPIOG4 = 1;
   GpioMuxRegs.GPGMUX.bit.SCIRXDB_GPIOG5 = 1;
   EDIS;

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize 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 DSP281x_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 DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
   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
   PieVectTable.RXAINT = &sciaRxFifoIsr;
   PieVectTable.TXAINT = &sciaTxFifoIsr;
   EDIS;   // This is needed to disable write to EALLOW protected registers


// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   scia_fifo_init();// Init SCI-A


// Step 5. User specific code, enable interrupts:
// Enable interrupts required for this example
   PieCtrlRegs.PIECRTL.bit.ENPIE = 1;   // Enable the PIE block
   PieCtrlRegs.PIEIER9.bit.INTx1=1;   // PIE Group 9, INT1
   PieCtrlRegs.PIEIER9.bit.INTx2=1;   // PIE Group 9, INT2
   IER = 1<<(9-1);        // Enable CPU INT   
        PieCtrlRegs.PIEACK.all|=0x100;      // Issue PIE ACK   0x100=1 0000 0000

   EINT;

// Step 6. IDLE loop. Just sit and loop forever (optional):
for(;;);

}




interrupt void sciaTxFifoIsr(void)
{
   SciaRegs.SCITXBUF=0xaa;
        SciaRegs.SCIFFTX.bit.TXINTCLR=1;        // Clear SCI Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x100;      // Issue PIE ACK   0x100=1 0000 0000
}

interrupt void sciaRxFifoIsr(void)
{
//Add user code here
   Uint16 i;
    i=SciaRegs.SCIRXBUF.all;       // Read data

       

        SciaRegs.SCIFFRX.bit.RXFFOVRCLR=1;   // Clear Overflow flag 清除溢出标志
        SciaRegs.SCIFFRX.bit.RXFFINTCLR=1;   // Clear Interrupt flag
        PieCtrlRegs.PIEACK.all|=0x100;       // Issue PIE ack
}

void scia_fifo_init()
{
   SciaRegs.SCICCR.all =0x0007;   // 1 stop bit,No loopback
                                  // No parity,8 char bits,
                                  // async mode, idle-line protocol
   SciaRegs.SCICTL1.all =0x0003;// enable TX, RX, internal SCICLK,
                                  // Disable RX ERR, SLEEP, TXWAKE
   SciaRegs.SCICTL2.bit.TXINTENA =1; //Transmit interrupt enable
   SciaRegs.SCICTL2.bit.RXBKINTENA =1; // Receiver Or buffer break interrupt enable
   SciaRegs.SCIHBAUD =0x0001;//高 8 位
   SciaRegs.SCILBAUD =0x00E7;//低 8 位
   SciaRegs.SCICCR.bit.LOOPBKENA =0; // Disable loop back

   //Interrupt level:1 发送FIFO深度为8字节
   //FIFO Interrupt enable
   //Enhancement enable
   //SCI reset rx/tx channels
   SciaRegs.SCIFFTX.all=0xC021; //1100 0000 0010 0001
   SciaRegs.SCIFFRX.all=0x0021;
   SciaRegs.SCIFFCT.all=0x00;

   SciaRegs.SCICTL1.all =0x0023;   // Relinquish SCI from Reset
   SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;
   SciaRegs.SCIFFRX.bit.RXFIFORESET=1;


}

//===========================================================================
// No more.
//===========================================================================

lindabell 发表于 2011-3-28 15:18:49

解决了。我看错了,我把FIFO中断看出发送中断了。


后加:
    我想把串口中断的服务程序放在sci.c中,但在哪里声明啊,在sci.h中吗;我看sci.h放有很多东西啊
    请高手帮帮我,你们是放在哪里的
页: [1]
查看完整版本: DSP 2812 串口方式怎么发生数据的(没辙了)