网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> DSP >> 代码示例 >> TI DSP代码示例 >> C2000 >> 文章正文
  TMS320F2812 SCI_FFDLB范例程序         ★★★ 【字体:
TMS320F2812 SCI_FFDLB范例程序
作者:61IC    文章来源:本站原创    点击数:    更新时间:2007-1-16    

//
//      TMDX ALPHA RELEASE
//      Intended for product evaluation purposes
//
//###########################################################################
//
// FILE: Example_28xSci_FFDLB.c
//
// TITLE: DSP28 Device SCI FIFO Digital Loop Back Test.
//
// ASSUMPTIONS:
//
//          This program requires the DSP28 header files.  To compile the
//          program as is, it should reside in the DSP28/examples/sci_loopback
//          sub-directory.
//
//          As supplied, this project is configured for "boot to H0" operation. 
//
// DESCRIPTION:
//
//          This test uses the loopback test mode of the SCI module to send
//          characters starting with 0x00 through 0xFF.  The test will send
//          a character and then check the receive buffer for a correct match.
//
//          Watch Variables:
//                LoopCount for the number of characters sent
//                ErrorCount
//  
//
//###########################################################################
//
//  Ver | dd mmm yyyy | Who  | Description of changes
// =====|=============|======|===============================================
//  0.56| 06 May 2002 | S.S. | EzDSP Alpha Release
//  0.57| 27 May 2002 | L.H. | No change
//  0.58| 08 July2002 | S.S. | Sci example 
//###########################################################################


#include "DSP28_Device.h"

// Prototype statements for functions found within this file.
void scia_loopback_init(void);
void scia_fifo_init(void); 
void scia_xmit(int a);
void error(int);
interrupt void scia_rx_isr(void);
interrupt void scia_tx_isr(void);

// Global counts used in this example
Uint16 LoopCount;
Uint16 ErrorCount;

void main(void)
{
    Uint16 SendChar;
    Uint16 ReceivedChar;
   
// Step 1. Initialize System Control registers, PLL, WatchDog, Clocks to default state:
        // This function is found in the DSP28_SysCtrl.c file.
 InitSysCtrl();

// Step 2. Select GPIO for the device or for the specific application:
       // This function is found in the DSP28_Gpio.c file.
       // InitGpio(); skip this as this is example selects the I/O for SCI in this file itself
    EALLOW;
    GpioMuxRegs.GPFMUX.all=0x0030; // Select GPIOs to be Sci pins 
                                    // Port F MUX - x000 0000 0011 0000
    EDIS;

// Step 3. Initialize PIE vector table:
      // The PIE vector table is initialized with pointers to shell Interrupt
      // Service Routines (ISR).  The shell routines are found in DSP28_DefaultIsr.c.
      // Insert user specific ISR code in the appropriate shell ISR routine in
      // the DSP28_DefaultIsr.c file.

      // Disable and clear all CPU interrupts:
 DINT;
 IER = 0x0000;
 IFR = 0x0000;

      // Initialize Pie Control Registers To Default State:
      // This function is found in the DSP28_PieCtrl.c file.
   // InitPieCtrl();  PIE is not used for this example

      // Initialize the PIE Vector Table To a Known State:
      // This function is found in DSP28_PieVect.c.
      // This function populates the PIE vector table with pointers
      // to the shell ISR functions found in DSP28_DefaultIsr.c.
   InitPieVectTable(); 
 
// Step 4. Initialize all the Device Peripherals to a known state:
      // This function is found in DSP28_InitPeripherals.c
      // InitPeripherals(); skip this for SCI tests
 
// Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:

    LoopCount = 0;
    ErrorCount = 0;
   
    scia_fifo_init();    // Initialize the SCI FIFO
    scia_loopback_init();  // Initalize SCI for digital loop back

    // Note: Autobaud lock is not required for this example
   
    // Send a character starting with 0
    SendChar = 0;        

// Step 6. Send Characters forever starting with 0x00 and going through
// 0xFF.  After sending each, check the recieve buffer for the correct value

 for(;;)
    {
       scia_xmit(SendChar);
       while(SciaRegs.SCIFFRX.bit.RXFIFST !=1) { } // wait for XRDY =1 for empty state
 
       // Check received character
       ReceivedChar = SciaRegs.SCIRXBUF.all;   
       if(ReceivedChar != SendChar) error(1);

       // Move to the next character and repeat the test
       SendChar++;
       // Limit the character to 8-bits
       SendChar &= 0x00FF;
       LoopCount++;
    }

}  


// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here: 

void error(int ErrorFlag)
{
      ErrorCount++;
//    asm("     ESTOP0");  // Uncomment to stop the test here
//    for (;;);

}

// Test 1,SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void scia_loopback_init()
{   
    // Note: Clocks were turned on to the SCIA peripheral
    // in the InitSysCtrl() function
   
  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.all =0x0003;
 SciaRegs.SCICTL2.bit.TXINTENA =1;
 SciaRegs.SCICTL2.bit.RXBKINTENA =1;
    SciaRegs.SCIHBAUD    =0x0000;
    SciaRegs.SCILBAUD    =0x000F;
 SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back 
 SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset
}

// Transmit a character from the SCI'
void scia_xmit(int a)
{
    SciaRegs.SCITXBUF=a;
}   

// Initalize the SCI FIFO
void scia_fifo_init()          
{
    SciaRegs.SCIFFTX.all=0xE040;
    SciaRegs.SCIFFRX.all=0x204f;
    SciaRegs.SCIFFCT.all=0x0;
   

                       
 
   


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

               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    TMS320F2812的SPWM原程序
    基于LabVIEW和TMS320F2812的…
    TMS320F2812的CAN调试成功经…
    基于TMS320F2812和μC/OS II…
    TMS320F2812 全局汇编函数
    TMS320F2812 CMD 文件各段含…
    基于TMS320F2812集中供电系统…
    TMS320F2812的CMD文件配置详…
    基于TMS320F2812的多轴伺服控…
    利用TMS320F2812 DSP&DRV592…
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号