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发送无效 |