#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
void main()
{
int timerTicks;
long int i,j;
char * strPtr; // Parameter pointer
unsigned char Command_AT[] ={0x41,0x54,0x0D};
unsigned char Command_CALL[16] ={0x41,0x54,0x44,0x31,0x35,0x31,0x32,0x30,0x30,0x37,0x37,0x32,0x37,0x36,0x3B,0x0D};
UART_1_CmdReset(); // Initialize receiver/cmd
// buffer
UART_1_EnableInt(); // Enable RX interrupts
Counter8_1_WritePeriod(155); // Set up baud rate generator
Counter8_1_WriteCompareValue(77);
Counter8_1_Start(); // Turn on baud rate generator
UART_1_Start(UART_1_PARITY_NONE); // Enable UART
M8C_EnableGInt ; // Turn on interrupts
//UART_1_CPutString("\r\nWelcome to PSoC UART test program. V1.1 \r\n");
timerTicks = 0;
while(1) {
UART_1_PutString(Command_AT);
//UART_1_PutCRLF();
for(i=3000;i>=0;i--)
{for(j=100;j>=0;j--)
{timerTicks++;
if (timerTicks > 254)
timerTicks = 0;
}
}
strPtr = UART_1_szGetParam();
//UART_1_PutString(strPtr);
//UART_1_PutCRLF();
//while( 1 )
//{
UART_1_PutString(Command_CALL);
//UART_1_PutCRLF();
for(i=3000;i>=0;i--)
{for(j=1000;j>=0;j--)
{timerTicks++;
if (timerTicks > 254)
timerTicks = 0;
}
}
}
}
以上是我让psoc跟mc55通信的程序。我单独让psoc跟串口专家连接时,串口专家能够显示来自psoc的AT以及ATD……等,让mc55单独跟串口专家连接时,串口专家能够发送AT指令并且成功通信。但是让两者连接的时候单片机就不能给mc55发指令了,两者是通过RXD跟TXD交叉连接的。调试了两天都不行,只能求高手解答了,万分感谢 |