打印

关于cy8c29466串口调试问题

[复制链接]
816|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
SHILINCHUAN|  楼主 | 2017-4-1 10:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
CY8C29466用uart模块做串口通信,单片机能给上位机发送数据,上位机上不能发送数据给单片机。求大神指教。程序如下:
#include <m8c.h>
#include "PSoCAPI.h"  

void main(void)
{
    char * strPtr;                        // Parameter pointer
   
UART_CmdReset();                      // Initialize receiver/cmd
                                          // buffer
    UART_IntCntl(UART_ENABLE_RX_INT);     // Enable RX interrupts

    Counter8_WritePeriod(155);            // Set up baud rate generator
    Counter8_WriteCompareValue(77);
    Counter8_Start();                     // Turn on baud rate generator     

UART_Start(UART_PARITY_NONE);         // Enable UART
   
M8C_EnableGInt ;                      // Turn on interrupts
   
UART_CPutString("\r\nWelcome to PSoC UART test program. V1.1 \r\n");
   
while(1) {
       if(UART_bCmdCheck()) {                    // Wait for command  
if(strPtr = UART_szGetParam()) {       // More than delimiter"
             UART_CPutString("Found valid command\r\nCommand =>");  
   UART_PutString(strPtr);             // Print out command
   UART_CPutString("<\r\nParamaters:\r\n");  
   while(strPtr = UART_szGetParam()) { // loop on each parameter  
      UART_CPutString("   <");  
      UART_PutString(strPtr);          // Print each parameter  
      UART_CPutString(">\r\n");  
   }
}
UART_CmdReset();                          // Reset command buffer  
}
   }
}
配置//    Counter8  (placed in DBA03)
//      Clock         48MHz
//      Enable        High
//      Output        None
//      Period        155
//      CompareValue  78
//      CompareType   Less Than Or Equal
//      InterruptType Terminal Count
//
//    Using the settings above the UART baud rate can be calculated.
//    baud rate = 48MHz / ((Period+1) * (over Sample rate))
//              = 48MHz / ((155+1) * 8)
//              = 38.4 kBaud
//
//    The settings for the UART are as follows:
//
//    UART  (Placement RX => DAC06, TX => DCA07)
//      Clock              DBA03 Broadcast
//      RX Input           Global_IN_5
//      TX Output          Global_OUT_7
//      TX InterruptMode   TXComplete
//      RxCmdBuffer        Enable
//      RxBufferSize       16 Bytes
//      CommandTerminator  13      (CR)
//      Param_Delimiter    32      (space)
//      IgnoreCharsBelow   32      (Ignore all chars below space, except CR)
均是按照例程配置   但是不能用PC给单片机发命令。硬件连接无问题   pc上能打印Welcome to PSoC UART test program. V1.1    单PC发送无效
沙发
xyz549040622| | 2017-4-1 10:30 | 只看该作者
看到接收中断已经开启了,但是接收中断函数的配置在哪呢?

使用特权

评论回复
板凳
SHILINCHUAN|  楼主 | 2017-4-1 10:53 | 只看该作者
xyz549040622 发表于 2017-4-1 10:30
看到接收中断已经开启了,但是接收中断函数的配置在哪呢?

接收的中断函数需要在while循环外自己添加吗?第一次使用POSC,还不太懂中断咋个配置。求指教。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

4

帖子

0

粉丝