// TI File $Revision: /main/8 $
// Checkin $Date: August 15, 2007 09:45:52 $
//###########################################################################
//
// FILE: Example_2833xSci_FFDLB.c
//
// TITLE: DSP2833x Device SCI FIFO Digital Loop Back Test.
//
// ASSUMPTIONS:
//
// This program requires the DSP2833x 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 2833x 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:
//
// GPIO87 GPIO86 GPIO85 GPIO84
// XA15 XA14 XA13 XA12
// PU PU PU PU
// ==========================================
// 1 1 1 1 Jump to Flash
// 1 1 1 0 SCI-A boot
// 1 1 0 1 SPI-A boot
// 1 1 0 0 I2C-A boot
// 1 0 1 1 eCAN-A boot
// 1 0 1 0 McBSP-A boot
// 1 0 0 1 Jump to XINTF x16
// 1 0 0 0 Jump to XINTF x32
// 0 1 1 1 Jump to OTP
// 0 1 1 0 Parallel GPIO I/O boot
// 0 1 0 1 Parallel XINTF boot
// 0 1 0 0 Jump to SARAM <- "boot to SARAM"
// 0 0 1 1 Branch to check boot mode
// 0 0 1 0 Boot to flash, bypass ADC cal
// 0 0 0 1 Boot to SARAM, bypass ADC cal
// 0 0 0 0 Boot to SCI-A, bypass ADC cal
// Boot_Table_End$
//
// 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 Number of characters sent
// ErrorCount Number of errors detected
// SendChar Character sent
// ReceivedChar Character recieved
//
//
//###########################################################################
//
// Original Author: S.S.
//
// $TI Release: DSP2833x Header Files V1.01 $
// $Release Date: September 26, 2007 $
//###########################################################################
#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
#define SCIB 1
#define SCIC 0
// Prototype statements for functions found within this file.
void scib_loopback_init(void);
void scib_fifo_init(void);
void scib_xmit(int a);
void scic_loopback_init(void);
void scic_fifo_init(void);
void scic_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;
// 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;
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();
// Enable CPU and PIE interrupts
// This example function is found in the DSP2833x_PieCtrl.c file.
EnableInterrupts();
// 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;
ErrorCount = 0;
#if SCIB
scib_fifo_init(); // Initialize the SCI FIFO
scib_loopback_init(); // Initalize SCI
#elif SCIC
scic_fifo_init(); // Initialize the SCI FIFO
scic_loopback_init(); // Initalize SCI
#endif
// 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(;;)
{
#if SCIB
while(ScibRegs.SCIFFRX.bit.RXFFST == 0); { } // wait for RRDY/RXFFST =1 for 1 data available in FIFO
SendChar = ScibRegs.SCIRXBUF.all;
scib_xmit(SendChar);
while(ScibRegs.SCIFFTX.bit.TXFFST != 0);
#elif SCIC
while(ScicRegs.SCIFFRX.bit.RXFFST == 0); { } // wait for RRDY/RXFFST =1 for 1 data available in FIFO
SendChar = ScicRegs.SCIRXBUF.all;
scic_xmit(SendChar);
while(ScicRegs.SCIFFTX.bit.TXFFST != 0);
#endif
}
}
// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:
void error(int ErrorFlag)
{
Uint16 Error = ErrorFlag;
ErrorCount++;
asm(" ESTOP0"); // Uncomment to stop the test here
for (;;);
}
// Test 1,SCIB DLB, 8-bit word, baud rate 9.6K, default, 1 STOP bit, no parity
void scib_loopback_init()
{
// Note: Clocks were turned on to the SCIB peripheral
// in the InitSysCtrl() function
ScibRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScibRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScibRegs.SCICTL2.all =0x0003;
ScibRegs.SCICTL2.bit.TXINTENA =1;
ScibRegs.SCICTL2.bit.RXBKINTENA =1;
ScibRegs.SCIHBAUD =0x0001;
ScibRegs.SCILBAUD =0x00e7;
ScibRegs.SCICCR.bit.LOOPBKENA =0; // Disable loop back
ScibRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
// Transmit a character from the SCI'
void scib_xmit(int a)
{
ScibRegs.SCITXBUF=a;
}
// Initalize the SCI FIFO
void scib_fifo_init()
{
ScibRegs.SCIFFTX.bit.TXFIFOXRESET=0;
ScibRegs.SCIFFRX.bit.RXFIFORESET=0;
ScibRegs.SCIFFTX.all=0xE040;
ScibRegs.SCIFFRX.all=0x204f;
ScibRegs.SCIFFCT.all=0x0;
}
// Test 1,SCIC DLB, 8-bit word, baud rate 9.6k, 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
SCI功能开发例程,串口通讯调试.zip
版权申诉
112 浏览量
2021-12-30
20:59:21
上传
评论
收藏 232KB ZIP 举报
mYlEaVeiSmVp
- 粉丝: 1961
- 资源: 19万+
最新资源
- 以下是一些适用于英语六级作文的万能句型模板,涵盖了引言、正文和结论部分的各类表达方式.docx
- MATLAB中的非线性规划
- 进行C语言面试资格确认是招聘过程中一个重要的步骤,目的是确保候选人具备足够的C语言编程能力和知识.docx
- Java 轻量级的集群负载均衡设计
- 纹身师个人网站模板.jpg
- 在C语言中,连接两个字符串(即将一个字符串附加到另一个字符串的末尾)通常可以使用标准库中的 `strcat` 函数.docx
- 数据库管理工具:dbeaver-ce-23.1.1-stable.x86-64.rpm
- 以下是几个具体竞赛题目的详细解答,包括建模思路、方法和步骤 .docx
- 一份关于全国大学生建模大赛的相关教程!!
- 以下是关于计算机网络和现代通信组网的详细教程、案例和相关项目的推荐.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈