Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 通过uart中断接收字符串_String_Uart_Atmel - Fatal编程技术网

String 通过uart中断接收字符串

String 通过uart中断接收字符串,string,uart,atmel,String,Uart,Atmel,我正试图向我的董事会发送一些字符串。我是通过uart使用中断来完成的。问题是它不会接收整个字符串,而只接收最后一个字符 这是我的代码: void UART_Handler(void){ uint32_t status = uart_get_status(UART); //gets uart status register if(status & UART_SR_RXRDY){ //if there is a new character arrived uart_read(U

我正试图向我的董事会发送一些字符串。我是通过uart使用中断来完成的。问题是它不会接收整个字符串,而只接收最后一个字符

这是我的代码:

void UART_Handler(void){

uint32_t status = uart_get_status(UART); //gets uart status register

if(status & UART_SR_RXRDY){ //if there is a new character arrived

    uart_read(UART,&UART_RX_Buffer[UART_RX_Index]); //reads the character in a global buffer
    printf("\n\r ho letto %c; rxindex: %d\n\r",UART_RX_Buffer[UART_RX_Index],UART_RX_Index); //writes what he read

    if(UART_RX_Buffer[UART_RX_Index]== '#'){ //if the read character is # the string is complete and ready to be parsed
        UART_RX_Complete=1;
    }

    UART_RX_Index=(UART_RX_Index+1)%BUFF_SIZE; //increments the buffer index
}
每次接收到一个字节时设置中断。
如果我一次发送一个字符,代码运行得很好,但我需要立即发送整个字符串。

您是从中断处理程序调用printf吗?在你的平台上安全吗?为什么不安全?printf通过uart发送数据。。。不过我会试试的!真是难以置信!非常感谢,伙计: