6606|13

35

帖子

0

TA的资源

一粒金砂(中级)

楼主
 

TMS320F28027中SCI-FIFO求助 [复制链接]

一直没有理解SCI中FIFO堆栈,例程中的红色字体的数据流是怎样发送与接收的呢?开始发送的是00么?接收到的数据是存在FIFO中还是RXBUFER中呢?例程中rdataA=SciaRegs.SCIRXBUF.all;         // Read data  初学DSP太多有不明白的,跪求大神,虚心受教




// TI File $Revision: /main/3 $

// Checkin $Date: December 17, 2009   14:36:39 $

//###########################################################################

//

// FILE:   Example_2802xSci_FFDLB_int.c

//

// TITLE:  DSP2802x Device SCI Digital Loop Back porgram.

//

//

// ASSUMPTIONS:

//

//    This program requires the DSP2802x header files.

//

//    This program uses the internal loop back test mode of the peripheral.

//    Other then boot mode pin configuration, no other hardware configuration

//    is required.

//

//    As supplied, this project is configured for "boot to SARAM"

//    operation.  The 2802x Boot Mode table is shown below.

//    For information on configuring the boot mode of an eZdsp,

//    please refer to the documentation included with the eZdsp,

//

//    $Boot_Table

//    While an emulator is connected to your device, the TRSTn pin = 1,

//    which sets the device into EMU_BOOT boot mode. In this mode, the

//    peripheral boot modes are as follows:

//

//      Boot Mode:   EMU_KEY        EMU_BMODE

//                   (0xD00)             (0xD01)

//      ---------------------------------------

//      Wait                 !=0x55AA        X

//      I/O                     0x55AA                 0x0000

//      SCI                     0x55AA                 0x0001

//      Wait              0x55AA                 0x0002

//      Get_Mode         0x55AA                 0x0003

//      SPI                     0x55AA                 0x0004

//      I2C                     0x55AA                 0x0005

//      OTP                     0x55AA                 0x0006

//      Wait                 0x55AA                 0x0007

//      Wait                 0x55AA                 0x0008

//      SARAM                 0x55AA                 0x000A          <-- "Boot to SARAM"

//      Flash                 0x55AA                 0x000B

//            Wait                 0x55AA          Other

//

//   Write EMU_KEY to 0xD00 and EMU_BMODE to 0xD01 via the debugger

//   according to the Boot Mode Table above. Build/Load project,

//   Reset the device, and Run example

//

//   $End_Boot_Table

//

//   Assumes the device has both SCI-A and SCI-B peripherals.

//

// DESCRIPTION:

//

//    This program is a SCI example that uses the internal loopback of

//    the peripheral.  Both interrupts and the SCI FIFOs are used.

//

//    A stream of data is sent and then compared to the recieved stream.

//

//    The SCI-A sent data looks like this:

//    00 01

//    01 02

//    02 03

//    ....

//    FE FF

//    FF 00

//    etc..

//

//

//

//    The pattern is repeated forever.

//

//    Watch Variables:

//       sdataA             Data being sent

//       rdataA             Data received

//       rdata_pointA       Keep track of where we are in the datastream

//                         This is used to check the incoming data

//###########################################################################

// Original Source by S.D.

//

// $TI Release: 2802x Header Files V1.27 $

// $Release Date: June 28, 2010 $

//###########################################################################



#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File



#define CPU_FREQ         6E6        // Default = 40 MHz. Change to 60E6 for 60 MHz devices

#define LSPCLK_FREQ CPU_FREQ/4

#define SCI_FREQ         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);

interrupt void scibTxFifoIsr(void);

interrupt void scibRxFifoIsr(void);

void scia_fifo_init(void);

void scib_fifo_init(void);

void error(void);



// Global variables

Uint16 sdataA[2];    // Send data for SCI-A

Uint16 rdataA[2];    // Received data for SCI-A

Uint16 rdata_pointA; // Used for checking the received data



void main(void)

{

   Uint16 i;



// Step 1. Initialize System Control:

// PLL, WatchDog, enable Peripheral Clocks

// This example function is found in the DSP2802x_SysCtrl.c file.

   InitSysCtrl();



// Step 2. Initalize GPIO:

// This example function is found in the DSP2802x_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

// This function is found in DSP2802x_Sci.c

   InitSciGpio();



// 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 DSP2802x_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 DSP2802x_DefaultIsr.c.

// This function is found in DSP2802x_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.SCIRXINTA = &sciaRxFifoIsr;

   PieVectTable.SCITXINTA = &sciaTxFifoIsr;

   EDIS;   // This is needed to disable write to EALLOW protected registers



// Step 4. Initialize all the Device Peripherals:

// This function is found in DSP2802x_InitPeripherals.c

// InitPeripherals(); // Not required for this example

   scia_fifo_init();  // Init SCI-A



// Step 5. User specific code, enable interrupts:



// Init send data.  After each transmission this data

// will be updated for the next transmission

   for(i = 0; i<2; i++)

   {

      sdataA = i;

   }



   rdata_pointA = sdataA[0];

// Enable interrupts required for this example

   PieCtrlRegs.PIECTRL.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 = 0x100;        // Enable CPU INT

   EINT;



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

        for(;;);



}



void error(void)

{

    asm("     ESTOP0"); // Test failed!! Stop!

    for (;;);

}



interrupt void sciaTxFifoIsr(void)

{

    Uint16 i;

    for(i=0; i< 2; i++)

    {

           SciaRegs.SCITXBUF=sdataA;     // Send data

        }



    for(i=0; i< 2; i++)                 //Increment send data for next cycle

    {

           sdataA = (sdataA+1) & 0x00FF;

        }



        SciaRegs.SCIFFTX.bit.TXFFINTCLR=1;        // Clear SCI Interrupt flag

        PieCtrlRegs.PIEACK.all|=0x100;      // Issue PIE ACK

}



interrupt void sciaRxFifoIsr(void)

{

    Uint16 i;

        for(i=0;i<2;i++)

        {

           rdataA=SciaRegs.SCIRXBUF.all;         // Read data

        }

        for(i=0;i<2;i++)                     // Check received data

        {

           if(rdataA != ( (rdata_pointA+i) & 0x00FF) ) error();

        }

        rdata_pointA = (rdata_pointA+1) & 0x00FF;



        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;

   SciaRegs.SCICTL2.bit.RXBKINTENA =1;

   SciaRegs.SCIHBAUD = 0x0000;

   SciaRegs.SCILBAUD = SCI_PRD;

   SciaRegs.SCICCR.bit.LOOPBKENA =1; // Enable loop back

   SciaRegs.SCIFFTX.all=0xC022;

   SciaRegs.SCIFFRX.all=0x0022;

   SciaRegs.SCIFFCT.all=0x00;



   SciaRegs.SCICTL1.all =0x0023;     // Relinquish SCI from Reset

   SciaRegs.SCIFFTX.bit.TXFIFOXRESET=1;

   SciaRegs.SCIFFRX.bit.RXFIFORESET=1;



}



//===========================================================================

// No more.

//===========================================================================




最新回复

他第一次是怎么进入中断的呢,一直没搞懂  详情 回复 发表于 2015-12-23 17:37
 
点赞 关注

回复
举报

450

帖子

1

TA的资源

一粒金砂(高级)

推荐
 
DSP最多可以使用16级深度的FIFO,如果不想用FIFO的话直接把深度设置为0即可;具体在这一句进行的设置:SciaRegs.SCIFFRX.all=0x0022;
 
个人签名君应有语,渺万里层云,千山暮雪,知向谁边?
 

回复

666

帖子

3

TA的资源

版主

沙发
 
这是sci的fifo回送程序。
建议先看懂sci标准使用模式,再尝试学习fifo。

点评

SCI标准模式自己看过,其中没有FIFO所以数据只需要到缓冲寄存器中,看到网上有说FIFO模式中数据收发都使用FIFO,TI这个程序中数据 都是直接从缓冲器中收发数据,rdataA=SciaRegs.SCIRXBUF.all; 那么缓冲器中的数  详情 回复 发表于 2015-4-9 21:50
 
 
 

回复

35

帖子

0

TA的资源

一粒金砂(中级)

板凳
 
nemo1991 发表于 2015-4-9 21:03
这是sci的fifo回送程序。
建议先看懂sci标准使用模式,再尝试学习fifo。

SCI标准模式自己看过,其中没有FIFO所以数据只需要到缓冲寄存器中,看到网上有说FIFO模式中数据收发都使用FIFO,TI这个程序中数据

都是直接从缓冲器中收发数据,rdataA=SciaRegs.SCIRXBUF.all; 那么缓冲器中的数据进入FIFO的数据 rdata不就得不到了么, 好难理解啊


 
 
 

回复

666

帖子

3

TA的资源

版主

4
 
FIFO中的数据,就是通过SCIRXBUF进行读取。
 
 
 

回复

1万

帖子

28

TA的资源

裸片初长成(高级)

6
 
楼主如果认真看 《 SPRUGH1C 》 这个文档,应该不难理解FIFO的。

如果不使用FIFO,一次只能写入TX一个数据,等发送完后再写第二个数据。如果使用FIFO,如四级,就可以一下子写入四个数据,写入的地址还是发送数据寄存器。

点评

对,这样利用中断的时候响应的次数可以减少,但我看到例程中读取数据时还是从缓冲寄存器中读取,而不是从FIFO中读取的,这是为什么呢?数据不是在FIFO中么  详情 回复 发表于 2015-4-13 10:34
 
 
 

回复

35

帖子

0

TA的资源

一粒金砂(中级)

7
 
查看本帖全部讨论,请登录或者注册

点评

自动完成的。。。 就是通过buffer读取。  详情 回复 发表于 2015-4-13 10:45
 
 
 

回复

666

帖子

3

TA的资源

版主

8
 
查看本帖全部讨论,请登录或者注册

点评

也就是读取数据总是需要借助buffer来自动读取么,  详情 回复 发表于 2015-4-13 10:48
 
 
 

回复

35

帖子

0

TA的资源

一粒金砂(中级)

9
 
查看本帖全部讨论,请登录或者注册

点评

是这样的。 另外,28335 fifo是16级,但是28027只有4级。 参考某些程序时候需要注意。  详情 回复 发表于 2015-4-13 20:45
 
 
 

回复

35

帖子

0

TA的资源

一粒金砂(中级)

10
 
查看本帖全部讨论,请登录或者注册
 
 
 

回复

666

帖子

3

TA的资源

版主

11
 
查看本帖全部讨论,请登录或者注册

点评

OK,非常感谢  详情 回复 发表于 2015-4-13 21:43
OK,非常感谢  详情 回复 发表于 2015-4-13 21:43
 
 
 

回复

35

帖子

0

TA的资源

一粒金砂(中级)

12
 
查看本帖全部讨论,请登录或者注册
 
 
 

回复

35

帖子

0

TA的资源

一粒金砂(中级)

13
 
查看本帖全部讨论,请登录或者注册
 
 
 

回复

9

帖子

0

TA的资源

一粒金砂(初级)

14
 
查看本帖全部讨论,请登录或者注册
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
【干货上新】电源解决方案和技术第二趴 | DigiKey 应用探索站
当月好物、电源技术资源、特色活动、DigiKey在线实用工具,干货多多~

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网 3

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表