I am attempting to send 13 bytes over UARTE1 on the nRF52840. I'm using the ASYNC API in Zephyr. When I look at the output on an oscilloscope, some of the bytes show up in the sent pattern. However, there are 2+ extra bytes that are sent along with the intended bytes; also, those extra bits are interspersed through the data I want. It's almost as if the data in the buffer are being corrupted during the transmission, but when I view those data in memory during debugging, they are the bytes I set.
I have set up the device with no parity bit and one stop bit. Could another setting account for the additional bits?
Here is the relevant code:
u8_t testBuffer[13] = {0xA5, 0x01, 0xF2, 0x00, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x61, 0x2F, 0x52, 0xEF}; void uartTXCallback(struct uart_event* evt, void* user_data){ switch(evt->type){ case UART_TX_DONE: printk("UART_TX_DONE\n"); for(int i = 0; i<evt->data.tx.len;++i) printk("%x:",evt->data.tx.buf[i]); printk("\n"); break; case UART_TX_ABORTED: printk("UART_TX_ABORTED\n"); break; case UART_RX_RDY: printk("UART_RX_RDY\n"); break; case UART_RX_BUF_REQUEST: printk("UART_RX_BUF_REQUEST\n"); break; case UART_RX_BUF_RELEASED: printk("UART_RX_BUF_RELEASED\n"); break; case UART_RX_DISABLED: printk("UART_RX_DISABLED\n"); break; case UART_RX_STOPPED: printk("UART_RX_STOPPED\n"); break; default: printk("unknown event type!:%d\n", (int) evt->type); } } int main(){ //set up UART1: uart1dev = device_get_binding(DT_LABEL(DT_NODELABEL(uart1))); int err; err = uart_callback_set(uart1dev, uartTXCallback, NULL); //(uart_callback_t) if(err != 0){ //printk("Error setting callback fn for UARTE1 tx:%d\n",err); return; } size_t bufLen = sizeof(testBuffer); while(1){ err=uart_tx(uart1dev, testBuffer, bufLen, 200); if(err != 0){ printk("Something's up with the transmission: %d.\n", err); } k_busy_wait(200000); } }