Page 1 of 1
Modbus setting
Posted: Sat Nov 24, 2018 11:54 am
by markavo42
Hello
Is there a way to change the default modbus setting
Data bits / Parity / stop bits.
What is the default settings ? as i can only seem to find and change the baud rate.
My slave only allows the configuration of multiple speeds but with fixed:
1 / 8 bits / Even
I think this is my reason why i see no responses from the slave to the arm master using flowcode.
Is there a way to just change the parity to Even from none ?
Thank you.

Re: Modbus setting
Posted: Mon Nov 26, 2018 12:49 pm
by markavo42
Anyone any ideas or comments please.
Thank you.
Re: Modbus setting
Posted: Mon Nov 26, 2018 5:56 pm
by Benj
Hello,
Currently the mode is.
1 stop bit
8 data bits
no parity
Which ARM device are you using and I will investigate how tricky adding parity would be. It might be very simple to switch on.
If you're using the ST-ARM devices then it looks like it should be fairly simple.
Simply edit the following file using a text editor.
"C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\STARM\STARM_CAL_UART.c"
Please note that the ProgramData folder is hidden by default so simply paste the full path into a Windows explorer address bar.
C:\ProgramData\MatrixTSL\FlowcodeV8\CAL\STARM\
Look around line 228 and you should see a line of code like this.
Code: Select all
MX_UART_HANDLE_X.Init.Parity = UART_PARITY_NONE;
Try changing it to this instead.
Code: Select all
MX_UART_HANDLE_X.Init.Parity = UART_PARITY_EVEN;
Save the file and hopefully that is all that is required.
If you run the update system (help -> Check for updates) it will flag the CAL .c file as invalid and if downloaded will overwrite with the official file so you can easily go back to stock at any point if you need to.
Re: Modbus setting
Posted: Tue Nov 27, 2018 2:02 pm
by markavo42
Thank you. Just tested
Leaving the parity as NONE in the STARM_CAL_UART.c
I the monitor the coms on the 9 way’D application set to NONE
a good result SENT IS
01 05 00 01 ff 00 dd fa
Setting the parity as EVEN in the STARM_CAL_UART.c
I the monitor the coms on the 9 way’D application set to EVEN
The bad result SENT IS
81 41 81 00 77 ff
I check again by changing the monitoring application to NONE leaving Leaving STARM_CAL_UART.c
on EVEN.
The bad result SENT IS
81 05 00 81 ff 00 dd fa
I’m using STARM 746 any more suggestions please to allow me to change to EVEN as the salve is fixed on EVEN i wish to talk to.
Is it something to do with the 9th bit do i need to enable this some way please ?
Thank you for you support.

Re: Modbus setting
Posted: Tue Nov 27, 2018 4:32 pm
by markavo42
OK some news
by changing to EVEN it did not help but by also changing 8B to 9B and to EVEN it worked !
but i have a new issue i also have a display connected to a different UART and i guess this is parity NONE so as you may of guessed now the display will not talk to the ST-ARM
Any work around for this please ?
Changing 8B to 9B will it cause any more issues you can think of ?
Thank you,
//MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_8B;
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_9B;
Code: Select all
#if(MX_UART_DBITS_X == 9)
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_9B;
#else
//MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_8B;
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_9B;
#endif
MX_UART_HANDLE_X.Init.StopBits = UART_STOPBITS_1;
MX_UART_HANDLE_X.Init.Parity = UART_PARITY_EVEN;
MX_UART_HANDLE_X.Init.HwFlowCtl = UART_HWCONTROL_NONE;
MX_UART_HANDLE_X.Init.Mode = UART_MODE_TX_RX;
MX_UART_HANDLE_X.Init.OverSampling = UART_OVERSAMPLING_16;
Re: Modbus setting
Posted: Tue Nov 27, 2018 5:42 pm
by Benj
Hello,
You should be able to use the preprocessor to do different code.
For example to override only channel 1 and leave other channels as was.
Code: Select all
#if (MX_UART_CHANNEL_X == 1)
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_9B;
MX_UART_HANDLE_X.Init.StopBits = UART_STOPBITS_1;
MX_UART_HANDLE_X.Init.Parity = UART_PARITY_EVEN;
#else
#if(MX_UART_DBITS_X == 9)
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_9B;
#else
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_8B;
#endif
MX_UART_HANDLE_X.Init.StopBits = UART_STOPBITS_1;
MX_UART_HANDLE_X.Init.Parity = UART_PARITY_NONE;
#endif
Re: Modbus setting
Posted: Wed Nov 28, 2018 12:57 pm
by markavo42
Thank you!
That did the trick.
Code: Select all
#if (MX_UART_CHANNEL_X > 0)
/* Enable USARTx clock */
MX_UART_CLOCK_X();
MX_UART_HANDLE_X.Instance = MX_UART_USART_X;
MX_UART_HANDLE_X.Init.BaudRate = MX_UART_BAUD_X;
////////////ADDED CHANNEL 3 FOR EVEN PARITY////////////
#if (MX_UART_CHANNEL_X == 4)
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_9B;
MX_UART_HANDLE_X.Init.StopBits = UART_STOPBITS_1;
MX_UART_HANDLE_X.Init.Parity = UART_PARITY_EVEN;
#else
#if(MX_UART_DBITS_X == 9)
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_9B;
#else
MX_UART_HANDLE_X.Init.WordLength = UART_WORDLENGTH_8B;
#endif
MX_UART_HANDLE_X.Init.StopBits = UART_STOPBITS_1;
MX_UART_HANDLE_X.Init.Parity = UART_PARITY_NONE;
#endif
////////////ADDED CHANNEL 3 FOR EVEN PARITY////////////
MX_UART_HANDLE_X.Init.HwFlowCtl = UART_HWCONTROL_NONE;
MX_UART_HANDLE_X.Init.Mode = UART_MODE_TX_RX;
MX_UART_HANDLE_X.Init.OverSampling = UART_OVERSAMPLING_16;