28335无法进入SCI FIFO中断问题探究

问题的关键在于SCIFFTX,SCIFFRX的bit一定要置1

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

// Prototype statements for functions found within this file.
void Scic_loopback_init(void);
void Scic_fifo_init(void);
void Scic_xmit(int a);
int  Scic_recv(void);
void error();

__interrupt void scicTxFifoIsr(void);
__interrupt void scicRxFifoIsr(void);

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

Uint16 sdataB[8];    // Send data for SCI-B
Uint16 rdataB[8];    // Received data for SCI-A

void main(void)
{
    Uint16 i;

// Step 1. Initialize System Control registers, PLL, WatchDog, Clocks to default state:
// This function is found in the DSP2833x_SysCtrl.c file.
	InitSysCtrl();

// Step 2. Select GPIO for the device or for the specific application:
// This function is found in the DSP2833x_Gpio.c file.
// InitGpio(); skip this as this is example selects the I/O
// for SCI-A in this file itself
   InitSciGpio();

// 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 DSP2833x_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;
	InitPieCtrl();
	IER = 0x0000;
	IFR = 0x0000;

// Initialize Pie Control Registers To Default State:
// This function is found in the DSP2833x_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 DSP2833x_PieVect.c.
// This function populates the PIE vector table with pointers
// to the shell ISR functions found in DSP2833x_DefaultIsr.c.
    InitPieVectTable();

    EALLOW;  // This is needed to write to EALLOW protected registers
    PieVectTable.SCIRXINTC = &scicRxFifoIsr;
    PieVectTable.SCITXINTC = &scicTxFifoIsr;
    EDIS;   // This is needed to disable write to EALLOW protected registers

// Enable CPU and PIE interrupts
// This example function is found in the DSP2833x_PieCtrl.c file.
    PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
    PieCtrlRegs.PIEIER8.bit.INTx5=1;     // PIE Group 9, int1
    PieCtrlRegs.PIEIER8.bit.INTx6=1;     // PIE Group 9, INT2

    IER|=M_INT8; // Enable CPU INT
    EINT;

// Step 4. Initialize all the Device Peripherals to a known state:
// This function is found in DSP2833x_InitPeripherals.c
// InitPeripherals(); skip this for SCI tests

// Step 5. User specific functions, Reassign vectors (optional), Enable Interrupts:

    LoopCount = 0;

    for(i = 0; i<8; i++)
    {
       sdataB[i] = 0xFF - i;
    }

    Scic_loopback_init();  // Initialize SCI for digital loop back

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

	for(;;)
    {
       LoopCount++;
    }
}

// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:
void error()
{
    ErrorCount++;
    __asm("     ESTOP0");  // Uncomment to stop the test here
    for (;;);
}

// Test 1,Scic  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
void Scic_loopback_init()
{
    // Note: Clocks were turned on to the Scic peripheral
    // in the InitSysCtrl() function

 	ScicRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
                                   // No parity,8 char bits,
                                   // async mode, idle-line protocol
	ScicRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
                                   // Disable RX ERR, SLEEP, TXWAKE
    ScicRegs.SCIHBAUD    =0x0001;
    ScicRegs.SCILBAUD    =0x00E7;
    ScicRegs.SCIFFTX.all =0xE060; //bit5一定要置1使能中断,bit4~bit0表示缓冲多少个字节进中断
    ScicRegs.SCIFFRX.all =0x2068; //bit5一定要置1使能中断,bit4~bit0表示缓冲多少个字节进中断
    ScicRegs.SCIFFCT.all =0x0;

    ScicRegs.SCIFFTX.bit.TXFIFOXRESET=1;//重新使能发送fifo操作
    ScicRegs.SCIFFRX.bit.RXFIFORESET=1; //重新使能接收fifo操作
    ScicRegs.SCICTL1.all =0x0023;       // Relinquish SCI from Reset  重启sci
}

// Transmit a character from the SCI'
void Scic_xmit(int a)
{
    while(ScicRegs.SCICTL2.bit.TXRDY!=1){}
    ScicRegs.SCITXBUF = a;
}
int Scic_recv(void)
{
    while(SciaRegs.SCIRXST.bit.RXRDY!=1){} // wait for XRDY =1 for empty state
    return SciaRegs.SCIRXBUF.all;
}

__interrupt void scicTxFifoIsr(void)
{
    Uint16 i;
    for(i=0; i< 8; i++)
    {
       ScicRegs.SCITXBUF=sdataB[i];     // Send data
    }

    ScicRegs.SCIFFTX.bit.TXFFINTCLR=1;  // Clear Interrupt flag
    PieCtrlRegs.PIEACK.bit.ACK8=1;
}

__interrupt void scicRxFifoIsr(void)
{
    Uint16 i;
    for(i=0;i<8;i++)
    {
       rdataB[i]=ScicRegs.SCIRXBUF.all;  // Read data
    }

    ScicRegs.SCIFFRX.bit.RXFFOVRCLR=1;  // Clear Overflow flag
    ScicRegs.SCIFFRX.bit.RXFFINTCLR=1;  // Clear Interrupt flag
    PieCtrlRegs.PIEACK.bit.ACK8=1;
}

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

  • 4
    点赞
  • 0
    评论
  • 8
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

参与评论 您还未登录,请先 登录 后发表或查看评论
©️2022 CSDN 皮肤主题:书香水墨 设计师:CSDN官方博客 返回首页

打赏作者

qianshishangdi

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值