见附件,程序可能重新需要添加一些头文件,编译环境是CCSV6.0.0.
SCI中断接收,查询发送,调试通过。好像发送不了附件。呜呜
/*
* F28335_Sci_uart.c
* Created on: 2015年4月8日
*/
// TI File $Revision: /main/9 $
// Checkin $Date: April 21, 2008 15:43:19 $
//###########################################################################
// FILE: Example_2833xSci_Echoback.c
// Revised File: F28335SCI_UART_LCM_com.c,
// TITLE: DSP2833x Device SCI Echoback.
// Title: F28335SCI_UART_LCM_com;
// Date: 20150408,13:10:20;LHH;
// ASSUMPTIONS:
// This program requires the DSP2833x header files.
// As supplied, this project is configured for "boot to SARAM" operation.
// Connect the DSP F28335/SCI-B port to a LCM.
// 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 recieves and echo-backs data through the SCI-B port.
//
// 1) As is, the program configures SCI-B for 115200 baud with......;
// SYSCLKOUT = 150MHz and LSPCLK = 37.5 MHz
// SYSCLKOUT = 100MHz and LSPCLK = 25.0 Mhz
//
// baud rate=Lspclk/[(BRR+1)*8]
//
// Watch Variables:
// LoopCount for the number of characters sent
// ErrorCount
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
// Prototype statements for functions found within this file.
//void Scia_echoback_init(void);
void scia_fifo_init(void);
//void Scia_xmit(char *p);
//interrupt void cpu_timer0_isr(void);
//interrupt void scitx_a_isr(void); //150416;revised scia;
interrupt void scirx_a_isr(void);
Uint16 Count = 0; //debuging;//150417,LHH;
// Global variables
Uint16 i = 0;
Uint16 j = 0;
char *p1;
char *p2;
char sci_tx_buffer[8] = {0x55,0x55,0x04,0x80,0x53,0x55,0x11,0x33}; //发送数据数组;定义一个指针来传递数组;以fe为终止符;
char sci_rx_buffer[8]; //接收数据数组;
void main(void)
{
//Uint16 i;
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
InitSysCtrl();
// Step 2. Initalize GPIO:
InitSciaGpio(); //150416,LHH;
// 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 DSP2833x_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 DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
// PieVectTable.TINT0 = &cpu_timer0_isr;
//PieVectTable.SCITXINTA = &scitx_a_isr;
PieVectTable.SCIRXINTA = &scirx_a_isr;
//PieVectTable.SCITXINTB = &scitx_b_isr;
//PieVectTable.SCIRXINTB = &scirx_b_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Step 4. Initialize all the Device Peripherals:
scia_fifo_init(); //150416;
PieCtrlRegs.PIEIER9.bit.INTx1=1; // PIE Group 9, INT1 receive,SCIA
IER |= M_INT9; //Enale INT9,SCI Interrupt;150417,LHH;
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
// Step 6. IDLE loop. Just sit and loop forever (optional):
//for(;;);
p1 = sci_tx_buffer; //数组名对应的就是数组的首地址;
while(1)
{
DELAY_US(1000000L); //延时10ms;
for(i = 0;i < 8; i++)
{
p1++;
p1 = sci_tx_buffer;
}
for(i=0;i < 8;i++,p1++)
{
while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
SciaRegs.SCITXBUF = *p1;
}
}
}
interrupt void scirx_a_isr(void)
{
Count++;
p2 = sci_rx_buffer;
for(j = 0;j < 8; j++)
{
p2++;
p2 = sci_rx_buffer;
}
for(j=0;j < 8;j++,p2++)
{
while (SciaRegs.SCIFFRX.bit.RXFFST == 0) {}
*p2 = SciaRegs.SCIRXBUF.all;
}
/*while (SciaRegs.SCIFFRX.bit.RXFFST == 0) {}
for(j=0; j<10; j++)
{
sci_rx_buffer[j]=SciaRegs.SCIRXBUF.all; // 将fifo中的数据读到缓存
}
j = 0;*/
SciaRegs.SCIFFTX.bit.TXFFINTCLR=1; // 很重要 若不清fifo发送中断标志则,不进入发送中断
SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // 清接收中断标志
PieCtrlRegs.PIEACK.all|=0x100; // Issue PIE ack
}
// Initalize the SCI FIFO
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.all =0x0003;
//SciaRegs.SCICTL2.bit.TXINTENA = 1;
// SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
/*SciaRegs.SCIHBAUD = 0x0001; //9600bps.
SciaRegs.SCILBAUD = 0x00E7;*/
SciaRegs.SCIHBAUD = 0x0000; //115200bps.
SciaRegs.SCILBAUD = 0x0027;
//SciaRegs.SCICCR.bit.LOOPBKENA =0; // disable loop back
SciaRegs.SCIFFTX.all = 0xE042;// 3-30 modified 0xe040 -> 0xe02e, enable transmit fifo interrupt, 14bits one time;改之前为E020;
SciaRegs.SCIFFRX.all = 0x0028;//3-28 modified 0x204f->0x002e ennable receive fifo interrupt
//SciaRegs.SCIFFRX.bit.RXFFOVRCLR = 1;//清接收fifo溢出标志
//SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;//清除接收fifo中断标志位
//SciaRegs.SCIFFRX.bit.RXFFIENA = 1;//屏蔽fifo 接收中断
//SciaRegs.SCIFFRX.bit.RXFFIL = 8; //fifo接收中断级别为8
SciaRegs.SCIFFCT.all = 0x0;
SciaRegs.SCICTL1.bit.SWRESET = 1;
SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
SciaRegs.SCIFFTX.bit.TXFIFOXRESET = 1;
SciaRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
}
// Transmit a character from the SCI
/*void Scia_xmit(char *p)
{
p = &sci_tx_buffer[8];
while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
SciaRegs.SCITXBUF = *p;
}*/
//===========================================================================
// No more.
//===========================================================================
|
这个程序直接可以与触摸屏通信吗?