HAL_UART_Transmit_DMA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-08 4:40 AM
i'veA question related to transmission using DMA. i'm facing a strange situation.
- it works perfectly when i use "HAL_UART_Transmit_DMA(&huart1, TxBuf, 5);" in the main program.
- However in my project i've crated a separate file for my application program, which i include in the main program, and when i call "HAL_UART_Transmit_DMA(&huart1, TxBuf, 5);" from my application program, only first two bytes are transferred as per my data rest all bytes are corrupted.
- Labels:
-
DMA
-
STM32F7 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-08 4:47 AM
Hello @NSing.5 ,
Thanks for sharing this issue.
To further analyze your problem could you please provide:
- The MCU you are using
- The CubeMx and you IDE versions
- The project you are working on or your *.ioc file if it is possible
Kind regards,
Aymen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-08 4:50 AM
Show the declaration of TxBuf (where exactly is it declared?) and check its usage (timing). You cannot write a new value to TxBuf until the transfer is finished.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-08 4:55 AM
Don't use local variable as buffer.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-09 1:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-09 1:07 AM
TxBuf is declared as local variable in the function that calls HAL_UART_Transmit_DMA(&huart1, TxBuf, 5); as follows:
void mstr_digno(uint8_t Device_address,uint16_t sub_code)
{
uint8_t TxBuf[25];
uint16_t crc_value=0;
TxBuf[0] = Device_address;
TxBuf[1] = 0x08; //operation code
convert_I_To_Byte(sub_code);
TxBuf[2] = IntegerToByte.high_byte;
TxBuf[3] = IntegerToByte.low_byte;
convert_I_To_Byte(Device_address);
TxBuf[4] = IntegerToByte.high_byte;
TxBuf[5] = IntegerToByte.low_byte;
crc_value = CRC_Cal_Value(TxBuf,5);
crc_value = crc_value&0xFFFF;
convert_I_To_Byte(crc_value);
TxBuf[6]=IntegerToByte.low_byte;
TxBuf[7]=IntegerToByte.high_byte;
//HAL_UART_Transmit_DMA(&huart1, TxBuf, 10);
HAL_UART_Transmit(&huart1, TxBuf, 10,10);
}
i'm writing new data to it after 2 seconds.
