请问为啥28335的SCIA的TI官方例程无法和串口调试工具通信啊?

[复制链接]
 楼主| Redbeannnnnn 发表于 2019-10-28 11:35 | 显示全部楼层 |阅读模式
例程是TI官网下载的,我把28335板子通过RS232连接到电脑上,想着通过串口调试助手进行收发数据测试,可是串口调试助手上什么都没有- -(PS:YS提供的SCI程序就可以正常通信,我看两者程序配置好像差不多)
  1. void main(void)
  2. {
  3.     Uint16 ReceivedChar;
  4.     char *msg;

  5. // Step 1. Initialize System Control:
  6. // PLL, WatchDog, enable Peripheral Clocks
  7. // This example function is found in the DSP2833x_SysCtrl.c file.
  8.    InitSysCtrl();

  9. // Step 2. Initialize GPIO:
  10. // This example function is found in the DSP2833x_Gpio.c file and
  11. // illustrates how to set the GPIO to it's default state.
  12.    // InitGpio(); Skipped for this example

  13. // For this example, only init the pins for the SCI-A port.
  14. // This function is found in the DSP2833x_Sci.c file.
  15.    InitSciaGpio();

  16. // Step 3. Clear all interrupts and initialize PIE vector table:
  17. // Disable CPU interrupts
  18.    DINT;

  19. // Initialize PIE control registers to their default state.
  20. // The default state is all PIE interrupts disabled and flags
  21. // are cleared.
  22. // This function is found in the DSP2833x_PieCtrl.c file.
  23.    InitPieCtrl();

  24. // Disable CPU interrupts and clear all CPU interrupt flags:
  25.    IER = 0x0000;
  26.    IFR = 0x0000;

  27. // Initialize the PIE vector table with pointers to the shell Interrupt
  28. // Service Routines (ISR).
  29. // This will populate the entire table, even if the interrupt
  30. // is not used in this example.  This is useful for debug purposes.
  31. // The shell ISR routines are found in DSP2833x_DefaultIsr.c.
  32. // This function is found in DSP2833x_PieVect.c.
  33.    InitPieVectTable();

  34. // Step 4. Initialize all the Device Peripherals:
  35. // This function is found in DSP2833x_InitPeripherals.c
  36. // InitPeripherals(); // Not required for this example

  37. // Step 5. User specific code:

  38.     LoopCount = 0;
  39.     ErrorCount = 0;

  40.     scia_fifo_init();           // Initialize the SCI FIFO
  41.     scia_echoback_init();  // Initialize SCI for echoback

  42.     msg = "\r\n\n\nHello World!\0";
  43.     scia_msg(msg);

  44.     msg = "\r\nYou will enter a character, and the DSP will echo it back! \n\0";
  45.     scia_msg(msg);

  46.         for(;;)
  47.     {
  48.        msg = "\r\nEnter a character: \0";
  49.        scia_msg(msg);

  50.        // Wait for inc character
  51.        while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for XRDY =1 for empty state
  52.        //while(SciaRegs.SCIRXST.bit.RXRDY !=1) { }

  53.        // Get character
  54.        ReceivedChar = SciaRegs.SCIRXBUF.all;

  55.        // Echo character back
  56.        msg = "  You sent: \0";
  57.        scia_msg(msg);
  58.        scia_xmit(ReceivedChar);

  59.        LoopCount++;
  60.     }
  61. }

  62. // Test 1,SCIA  DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity
  63. void scia_echoback_init()
  64. {
  65.     // Note: Clocks were turned on to the SCIA peripheral
  66.     // in the InitSysCtrl() function

  67.         SciaRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
  68.                                    // No parity,8 char bits,
  69.                                    // async mode, idle-line protocol
  70.         SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
  71.                                    // Disable RX ERR, SLEEP, TXWAKE
  72.         SciaRegs.SCICTL2.all =0x0003;
  73.         SciaRegs.SCICTL2.bit.TXINTENA =1;
  74.         SciaRegs.SCICTL2.bit.RXBKINTENA =1;
  75.         #if (CPU_FRQ_150MHZ)
  76.               SciaRegs.SCIHBAUD    =0x0001;  // 9600 baud @LSPCLK = 37.5MHz.
  77.               SciaRegs.SCILBAUD    =0x00E7;
  78.         #endif
  79.         #if (CPU_FRQ_100MHZ)
  80.       SciaRegs.SCIHBAUD    =0x0001;  // 9600 baud @LSPCLK = 20MHz.
  81.       SciaRegs.SCILBAUD    =0x0044;
  82.         #endif
  83.         SciaRegs.SCICTL1.all =0x0023;  // Relinquish SCI from Reset
  84. }

  85. // Transmit a character from the SCI
  86. void scia_xmit(int a)
  87. {
  88.     while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
  89.    // while (SciaRegs.SCICTL2.bit.TXRDY == 0) {}
  90.     SciaRegs.SCITXBUF=a;
  91. }

  92. void scia_msg(char * msg)
  93. {
  94.     int i;
  95.     i = 0;
  96.     while(msg[i] != '\0')
  97.     {
  98.         scia_xmit(msg[i]);
  99.         i++;
  100.     }
  101. }

  102. // Initialize the SCI FIFO
  103. void scia_fifo_init()
  104. {
  105.     SciaRegs.SCIFFTX.all=0xE040;
  106.     SciaRegs.SCIFFRX.all=0x204f;
  107.     SciaRegs.SCIFFCT.all=0x0;
  108. }
 楼主| Redbeannnnnn 发表于 2019-10-28 11:36 | 显示全部楼层
研究了两天了,小白真的伤不起啊,导师还让我做电机驱动,我连模块基本功能都跑不起来- -
zhangmangui 发表于 2019-10-28 22:36 | 显示全部楼层
从功能看    就是收到什么 上发什么    用串口助手发送数据  看看能不能接收到
zhangmangui 发表于 2019-10-28 22:37 | 显示全部楼层
电机控制做好必须要对C2000的外设做详细研究  结合数据手册研究
下载controlSUITE等TI的工具包
蒋博1026 发表于 2019-10-30 20:39 | 显示全部楼层
还是先搞清楚电机驱动的原理吧,原理搞懂了,后边就会轻松点
蒋博1026 发表于 2019-10-30 20:40 | 显示全部楼层
我还没用过DSP来搞电机的驱动,多看看数据手册吧,这种事也不能急
蒋博1026 发表于 2019-10-30 20:41 | 显示全部楼层
我之前只用过stm32做过控制电机,但是感觉原理应该是一样的,
蒋博1026 发表于 2019-10-30 20:42 | 显示全部楼层
stm32实现电机驱动,原理和DSP应该一样,只是实现的方式和实现的平台不一样
pengyoujianxiao 发表于 2019-11-6 14:19 | 显示全部楼层
学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

8

主题

34

帖子

0

粉丝
快速回复 返回顶部 返回列表