1
\$\begingroup\$

How do I transmit 16 bits of data with UART to a 16 bit array? I've got two elements in my array, my UART is set up as 8N1 and my DMA is set to circular.

I'm using some HAL stuff, and here's my setup:

extern uint16_t tx_buffer[2];
extern uint16_t rx_buffer[2];


  MX_DMA_Init();
  MX_USART1_UART_Init();
  HAL_UART_Receive_DMA(&huart1, (uint8_t *) rx_buffer, 4);

However, when I send a string of 4 8N1 bytes, my array looks like this:

p/z rx_buffer
{0x88, 0x00}

I've tried a few different permutation of changing the type for the pointer in the HAL_UART_Receive_DMA function as well as the type for the arrays...I've also tried 2 & 4 for the DMA length, but still nothing works.

Any idea why this is happening?

Thanks

\$\endgroup\$
3
\$\begingroup\$

Ahhh, I had my DMA transfer size set to word, not byte...

\$\endgroup\$
  • \$\begingroup\$ In STM32CubeMX, this setting is at the bottom of "DMA Configuration" popup. It's quite easy to be ignored. \$\endgroup\$ – qsun Jun 18 '18 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.