我正在尝试向我的电路板发送一些字符串(Atmel SAM3U)。我是通过使用中断的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
}
每次接收到一个字节时,都会设置中断。 如果我一次发送一个字符,代码工作得很好,但我需要立即发送整个字符串。