我用STM32实现串口的接收与发送,现在只能接收和发送一个字节,怎么接收和发送一个字符串,求详细代码
我现在的代码如下:#definecountof(a)(sizeof(a)/sizeof(*(a)))uint8_tTx_Buffer[]="good";staticvoi...
我现在的代码如下:
#define countof(a) (sizeof(a) / sizeof(*(a)))
uint8_t Tx_Buffer[] = "good";
static void delay (int cnt)
{
while (cnt--);
}
unsigned char RxBuf[10];
unsigned char index;
int main(void)
{
/* USART1 config 115200 8-N-1 */
USART_Configuration();
UART_Send( Tx_Buffer, countof(Tx_Buffer)-1);
delay(10000000);
while (1)
{
RxBuf[0] = USART_ReceiveData(USART1);
while(RxBuf[0] != 0x00)
{
//USART_SendData(USART1, RxBuf[0]);
UART_Send(RxBuf,1);
RxBuf[0] = 0x00;
}
}
} 展开
#define countof(a) (sizeof(a) / sizeof(*(a)))
uint8_t Tx_Buffer[] = "good";
static void delay (int cnt)
{
while (cnt--);
}
unsigned char RxBuf[10];
unsigned char index;
int main(void)
{
/* USART1 config 115200 8-N-1 */
USART_Configuration();
UART_Send( Tx_Buffer, countof(Tx_Buffer)-1);
delay(10000000);
while (1)
{
RxBuf[0] = USART_ReceiveData(USART1);
while(RxBuf[0] != 0x00)
{
//USART_SendData(USART1, RxBuf[0]);
UART_Send(RxBuf,1);
RxBuf[0] = 0x00;
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询