cancel
Showing results for 
Search instead for 
Did you mean: 

im trying to transmit hex array with 9600 8E1 in uart but it seems like weird.

HKang.4
Associate

I'm using STM32f103C8T6 Blue pill. for IDE is CUBEIDE and using HAL library

​wanna receive data from producted BMS module, then additionally control the mcu by received datas.

BMS communication module setting is 9600 8-Even-1 by 485 communication.

i wanna transmit like unsigned char tx1_tx[6] = {0x02, 0xAA, 0x01, 0xC1, 0x6C, 0x03}

I tested using 485 to USB module then, when I check the terminal, it seems like ok for communicating. actually i got the data what i want

(i attatched jpg file)

0693W00000Y9uXZQAZ.jpg 

the problem is that using the HAL library and setting 9600 8-E-1 for blue pill, such like attached jpg

0693W00000Y9uXtQAJ.jpgTx data seems like weird. Result is here

0693W00000Y9uXjQAJ.jpg 

in hal i write

​unsigned char tx1_data[6] = {0x02, 0xaa, 0x01, 0xc1, 0x6c, 0x03};

in side while

​HAL_GPIO_WritePin(rs485_GPIO_Port, rs485_Pin, GPIO_PIN_SET);

HAL_UART_Transmit(&huart1, tx1_data, 6, 10);

HAL_Delay(5000);

what should i do for this problem?

Thanks

3 REPLIES 3
Javier1
Principal

>>what should i do for this problem?

HAL_UART_Transmit(&huart1, tx1_data, sizeof(tx1_data), 100);//for starters

>>485 communication.

485 communication is half duplex, show us what kind of transceiver are you using, did you tested the transceiver alone?(bluepill is 3v3 , is your transceiver cool with that?)

are you getting consistenly the same wrong results?

we dont need to firmware by ourselves, lets talk
gbm
Lead III

Delay between activating the transceiver and transfer start?

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

Config in 9 bit mode to accommodate the parity bit.

ST includes it in the data payload, ie 8+1​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..