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

[复制链接]
3983|8
 楼主| jdliuhuihong 发表于 2015-12-12 10:59 | 显示全部楼层 |阅读模式
见附件,程序可能重新需要添加一些头文件,编译环境是CCSV6.0.0.
SCI中断接收,查询发送,调试通过。好像发送不了附件。呜呜
  1. /*
  2. * F28335_Sci_uart.c
  3. *  Created on: 2015年4月8日

  4. */
  5. //        TI File $Revision: /main/9 $
  6. //        Checkin $Date: April 21, 2008   15:43:19 $
  7. //###########################################################################
  8. //        FILE:        Example_2833xSci_Echoback.c
  9. //  Revised File:  F28335SCI_UART_LCM_com.c,
  10. //        TITLE:        DSP2833x Device SCI Echoback.
  11. //  Title:    F28335SCI_UART_LCM_com;
  12. //  Date:   20150408,13:10:20;LHH;
  13. //  ASSUMPTIONS:
  14. //  This program requires the DSP2833x header files.
  15. //  As supplied, this project is configured for "boot to SARAM" operation.
  16. //  Connect the DSP F28335/SCI-B port to a LCM.
  17. //    As supplied, this project is configured for "boot to SARAM"
  18. //    operation.  The 2833x Boot Mode table is shown below.
  19. //    For information on configuring the boot mode of an eZdsp,
  20. //    please refer to the documentation included with the eZdsp,
  21. //
  22. //       $Boot_Table:
  23. //
  24. //         GPIO87   GPIO86     GPIO85   GPIO84
  25. //          XA15     XA14       XA13     XA12
  26. //           PU       PU         PU       PU
  27. //        ==========================================
  28. //            1        1          1        1    Jump to Flash
  29. //            1        1          1        0    SCI-A boot
  30. //            1        1          0        1    SPI-A boot
  31. //            1        1          0        0    I2C-A boot
  32. //            1        0          1        1    eCAN-A boot
  33. //            1        0          1        0    McBSP-A boot
  34. //            1        0          0        1    Jump to XINTF x16
  35. //            1        0          0        0    Jump to XINTF x32
  36. //            0        1          1        1    Jump to OTP
  37. //            0        1          1        0    Parallel GPIO I/O boot
  38. //            0        1          0        1    Parallel XINTF boot
  39. //            0        1          0        0    Jump to SARAM            <- "boot to SARAM"
  40. //            0        0          1        1    Branch to check boot mode
  41. //            0        0          1        0    Boot to flash, bypass ADC cal
  42. //            0        0          0        1    Boot to SARAM, bypass ADC cal
  43. //            0        0          0        0    Boot to SCI-A, bypass ADC cal
  44. //                                              Boot_Table_End$
  45. // DESCRIPTION:
  46. //
  47. // This test recieves and echo-backs data through the SCI-B port.
  48. //
  49. // 1) As is, the program configures SCI-B for 115200 baud with......;
  50. //    SYSCLKOUT = 150MHz and LSPCLK = 37.5 MHz
  51. //    SYSCLKOUT = 100MHz and LSPCLK = 25.0 Mhz
  52. //
  53. //    baud rate=Lspclk/[(BRR+1)*8]
  54. //
  55. //    Watch Variables:
  56. //       LoopCount for the number of characters sent
  57. //       ErrorCount
  58. #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

  59. // Prototype statements for functions found within this file.
  60. //void Scia_echoback_init(void);
  61. void scia_fifo_init(void);
  62. //void Scia_xmit(char *p);
  63. //interrupt void cpu_timer0_isr(void);
  64. //interrupt void scitx_a_isr(void);  //150416;revised scia;
  65. interrupt void scirx_a_isr(void);
  66. Uint16 Count = 0;   //debuging;//150417,LHH;
  67. // Global variables
  68. Uint16 i = 0;
  69. Uint16 j = 0;
  70. char *p1;
  71. char *p2;
  72. char sci_tx_buffer[8] = {0x55,0x55,0x04,0x80,0x53,0x55,0x11,0x33};                  //发送数据数组;定义一个指针来传递数组;以fe为终止符;
  73. char sci_rx_buffer[8];                 //接收数据数组;
  74. void main(void)
  75. {
  76.         //Uint16 i;
  77.         // Step 1. Initialize System Control:
  78.         // PLL, WatchDog, enable Peripheral Clocks
  79.         // This example function is found in the DSP2833x_SysCtrl.c file.
  80.    InitSysCtrl();

  81.    // Step 2. Initalize GPIO:
  82.    InitSciaGpio();  //150416,LHH;

  83.    // Step 3. Clear all interrupts and initialize PIE vector table:
  84.    // Disable CPU interrupts
  85.    DINT;

  86.    // Initialize PIE control registers to their default state.
  87.    // The default state is all PIE interrupts disabled and flags
  88.    // are cleared.
  89.    // This function is found in the DSP2833x_PieCtrl.c file.
  90.    InitPieCtrl();

  91.    // Disable CPU interrupts and clear all CPU interrupt flags:
  92.    IER = 0x0000;
  93.    IFR = 0x0000;

  94.    // Initialize the PIE vector table with pointers to the shell Interrupt
  95.    // Service Routines (ISR).
  96.    // This will populate the entire table, even if the interrupt
  97.    // is not used in this example.  This is useful for debug purposes.
  98.    // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
  99.    // This function is found in DSP2833x_PieVect.c.
  100.    InitPieVectTable();
  101.    EALLOW;  // This is needed to write to EALLOW protected registers
  102.   // PieVectTable.TINT0 = &cpu_timer0_isr;
  103.    //PieVectTable.SCITXINTA = &scitx_a_isr;
  104.    PieVectTable.SCIRXINTA = &scirx_a_isr;
  105.    //PieVectTable.SCITXINTB = &scitx_b_isr;
  106.    //PieVectTable.SCIRXINTB = &scirx_b_isr;
  107.    EDIS;    // This is needed to disable write to EALLOW protected registers

  108.    // Step 4. Initialize all the Device Peripherals:
  109.               scia_fifo_init();       //150416;
  110.       PieCtrlRegs.PIEIER9.bit.INTx1=1;       // PIE Group 9, INT1  receive,SCIA
  111.       IER |= M_INT9;     //Enale INT9,SCI Interrupt;150417,LHH;
  112.    // Enable global Interrupts and higher priority real-time debug events:
  113.       EINT;   // Enable Global interrupt INTM
  114.       ERTM;   // Enable Global realtime interrupt DBGM

  115. // Step 6. IDLE loop. Just sit and loop forever (optional):
  116.      //for(;;);
  117.       p1 = sci_tx_buffer;     //数组名对应的就是数组的首地址;
  118.       while(1)
  119.       {
  120.               DELAY_US(1000000L);   //延时10ms;
  121.               for(i = 0;i < 8; i++)
  122.               {
  123.                       p1++;
  124.                       p1 = sci_tx_buffer;
  125.               }
  126.               for(i=0;i < 8;i++,p1++)
  127.               {
  128.                       while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
  129.                       SciaRegs.SCITXBUF = *p1;
  130.               }
  131.       }
  132. }
  133. interrupt void scirx_a_isr(void)
  134. {
  135.                 Count++;
  136.                  p2 = sci_rx_buffer;
  137.                  for(j = 0;j < 8; j++)
  138.                  {
  139.                     p2++;
  140.                     p2 = sci_rx_buffer;
  141.                   }
  142.                   for(j=0;j < 8;j++,p2++)
  143.                   {
  144.                          while (SciaRegs.SCIFFRX.bit.RXFFST == 0) {}
  145.                       *p2 = SciaRegs.SCIRXBUF.all;
  146.                    }
  147.             /*while (SciaRegs.SCIFFRX.bit.RXFFST == 0) {}
  148.             for(j=0; j<10; j++)
  149.             {
  150.                     sci_rx_buffer[j]=SciaRegs.SCIRXBUF.all; // 将fifo中的数据读到缓存
  151.             }
  152.             j = 0;*/
  153.             SciaRegs.SCIFFTX.bit.TXFFINTCLR=1;  // 很重要 若不清fifo发送中断标志则,不进入发送中断
  154.             SciaRegs.SCIFFRX.bit.RXFFINTCLR=1; // 清接收中断标志
  155.             PieCtrlRegs.PIEACK.all|=0x100;      // Issue PIE ack
  156. }
  157. // Initalize the SCI FIFO
  158. void scia_fifo_init()
  159. {
  160.             SciaRegs.SCICCR.all = 0x0007;   // 1 stop bit,  No loopback // No parity,8 char bits, // async mode, idle-line protocol
  161.         SciaRegs.SCICTL1.all = 0x0003;  // enable TX, RX, internal SCICLK,  // Disable RX ERR, SLEEP, TXWAKE
  162.         //SciaRegs.SCICTL2.all =0x0003;
  163.         //SciaRegs.SCICTL2.bit.TXINTENA = 1;
  164.        // SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
  165.         /*SciaRegs.SCIHBAUD    =   0x0001;                //9600bps.
  166.         SciaRegs.SCILBAUD    =   0x00E7;*/
  167.         SciaRegs.SCIHBAUD    =   0x0000;                //115200bps.
  168.         SciaRegs.SCILBAUD    =   0x0027;
  169.         //SciaRegs.SCICCR.bit.LOOPBKENA =0; // disable loop back

  170.         SciaRegs.SCIFFTX.all = 0xE042;// 3-30 modified 0xe040 -> 0xe02e, enable transmit fifo interrupt, 14bits one time;改之前为E020;
  171.         SciaRegs.SCIFFRX.all = 0x0028;//3-28 modified 0x204f->0x002e ennable receive fifo interrupt
  172.       //SciaRegs.SCIFFRX.bit.RXFFOVRCLR = 1;//清接收fifo溢出标志
  173.         //SciaRegs.SCIFFRX.bit.RXFFINTCLR = 1;//清除接收fifo中断标志位
  174.         //SciaRegs.SCIFFRX.bit.RXFFIENA = 1;//屏蔽fifo 接收中断
  175.         //SciaRegs.SCIFFRX.bit.RXFFIL = 8; //fifo接收中断级别为8

  176.         SciaRegs.SCIFFCT.all = 0x0;
  177.         SciaRegs.SCICTL1.bit.SWRESET = 1;
  178.         SciaRegs.SCIFFRX.bit.RXFIFORESET = 1;
  179.         SciaRegs.SCIFFTX.bit.TXFIFOXRESET = 1;
  180.         SciaRegs.SCICTL1.all = 0x0023;     // Relinquish SCI from Reset
  181. }
  182. // Transmit a character from the SCI
  183. /*void Scia_xmit(char *p)
  184. {
  185.         p = &sci_tx_buffer[8];
  186.     while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
  187.     SciaRegs.SCITXBUF = *p;
  188. }*/






  189. //===========================================================================
  190. // No more.
  191. //===========================================================================

打赏榜单

zhangmangui 打赏了 1.00 元 2015-12-12

评论

这个程序直接可以与触摸屏通信吗?  发表于 2019-1-21 14:01
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 | 显示全部楼层
感谢感谢   
 楼主| jdliuhuihong 发表于 2015-12-12 21:54 | 显示全部楼层

多多指教。。。。呵呵。。。
 楼主| jdliuhuihong 发表于 2015-12-12 21:58 | 显示全部楼层

谢谢版主的打赏。。。。
zhangmangui 发表于 2015-12-12 22:00 | 显示全部楼层
jdliuhuihong 发表于 2015-12-12 21:58
谢谢版主的打赏。。。。

哈哈  应该的    好东西   要分享
iuyi8 发表于 2018-6-28 15:57 | 显示全部楼层
我是新手,请问需要添加什么头文件
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

51

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部