发新帖本帖赏金 1.00元(功能说明)我要提问
返回列表
打印

分享前段时间调试通过的F28335—SCI串口触摸屏程序

[复制链接]
3496|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jdliuhuihong|  楼主 | 2015-12-12 10:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
见附件,程序可能重新需要添加一些头文件,编译环境是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.
//===========================================================================

打赏榜单

zhangmangui 打赏了 1.00 元 2015-12-12

评论
xiaoming1111 2019-1-21 14:01 回复TA
这个程序直接可以与触摸屏通信吗? 

相关帖子

沙发
comeon201208| | 2015-12-12 17:55 | 只看该作者
这个程序比较好,那有没有相对应的硬件原理图设计的也分享下的吧。

使用特权

评论回复
板凳
jdliuhuihong|  楼主 | 2015-12-12 21:48 | 只看该作者
comeon201208 发表于 2015-12-12 17:55
这个程序比较好,那有没有相对应的硬件原理图设计的也分享下的吧。

产品硬件电路,这个可能不大方便透露,因而也不是我主要设计的。所以...................
如果你有SCI触摸屏这块需求的话,倒是可以相互交流交流。

使用特权

评论回复
地板
zhangmangui| | 2015-12-12 21:50 | 只看该作者
感谢感谢   

使用特权

评论回复
5
jdliuhuihong|  楼主 | 2015-12-12 21:54 | 只看该作者

多多指教。。。。呵呵。。。

使用特权

评论回复
6
jdliuhuihong|  楼主 | 2015-12-12 21:58 | 只看该作者

谢谢版主的打赏。。。。

使用特权

评论回复
7
zhangmangui| | 2015-12-12 22:00 | 只看该作者
jdliuhuihong 发表于 2015-12-12 21:58
谢谢版主的打赏。。。。

哈哈  应该的    好东西   要分享

使用特权

评论回复
8
iuyi8| | 2018-6-28 15:57 | 只看该作者
我是新手,请问需要添加什么头文件

使用特权

评论回复
发新帖 本帖赏金 1.00元(功能说明)我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

51

帖子

1

粉丝