2023-03-08 04:40 AM
i'veA question related to transmission using DMA. i'm facing a strange situation.
2023-03-08 04:47 AM
Hello @NSing.5 ,
Thanks for sharing this issue.
To further analyze your problem could you please provide:
Kind regards,
Aymen
2023-03-08 04: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.
2023-03-08 04:55 AM
Don't use local variable as buffer.
JW
2023-03-09 01:00 AM
2023-03-09 01: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.