cancel
Showing results for 
Search instead for 
Did you mean: 

Why does HAL_UART_Transmit_DMA(&huart4, Buf,*Len); loose bytes if I call it in static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len) at /* USER CODE BEGIN 6 */ in usbd_cdc_if.c. Looks like DMA engine does not check TC

BSchm.0
Associate II
 
3 REPLIES 3
BSchm.0
Associate II

same problem if IRQ driven HAL_UART_Transmit_IT(&huart4, Buf,*Len); :(

too fast should be less or equalthen 115200

134985 bytes (135 kB, 132 KiB) copied, 0.19421 s, 695 kB/s

I only use code from HAL ! And in HAL_UART_IRQHandler(&huart4); the IDLE is not handled. If set you are trapped :(

BSchm.0
Associate II

The bytes are lost in the buffer of int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)

I write with dd if=test.bin of=/dev/ttyACM0

/home/one/test$ hexdump test.bin 
0000000 0100 0302 0504 0706 0908 0b0a 0d0c 0f0e
0000010 1110 1312 1514 1716 1918 1b1a 1d1c 1f1e
0000020 2120 2322 2524 2726 2928 2b2a 2d2c 2f2e
0000030 3130 3332 3534 3736 3938 3b3a 3d3c 3f3e

I read with cat /dev/ttyUSB0 > /home/one/test/read.txt on my own IRQ handler because you have to stop usb transfer until buffer is send by slower UART TX line with 115200

I read

/home/one/test$ hexdump read.txt 
0000000 0100 0302 0504 0706 0908 0b0a 0d0c 0f0e
0000010 1210 1514 1716 1918 1b1a 1d1c 1f1e 2120
0000020 2322 2524 2726 2928 2b2a 2d2c 2f2e 3130
0000030 3332 3534 3736 3938 3b3a 3d3c 3f3e 4140

And I can see this 1210 with lost 11 and lost 13 also in the receive buffer of USB. So my IRQ handler works :)

Here an example where byte with value 12 is missing, *len was 2

0690X000006CrF7QAK.png

Any ideas, I am trying now MX 5.0.0 cause I do not know why I loose the byte. UART IRQ prio is on 6 USB IRQ prio is on 5. But if I have both on 5 or UART on lower prio I could not get the data out of UART by IRQ handler TX :(

BSchm.0
Associate II

The chines FDTI clone used as receiver /dev/ttyUSB0 on TX of STM32 removes CR and LF