Hi Forum…
I am developing a modbus application for ESP32 using platformio and using this lib
The lib works and I used it to communicate with a ST mcu.
The setting that I used it is the following …
Serial2.begin(DEFAULT_BAUD_RATE_MODBUS, SERIAL_8E1, RXD_PIN, TXD_PIN);
The code it is trivial and the setting of the uart parameter are very clear…
On the other side I have a legacy code to modify from renesas MCU …
The code is the following…
void R_SCI12_Create(void)
{
/* Cancel SCI12 module stop state */
SYSTEM.MSTPCRB.BIT.MSTPB4 = 0U;
/* Set interrupt priority */
IPR(SCI12, ERI12) = _0F_SCI_PRIORITY_LEVEL15;
/* Clear the SCR.TIE, RIE, TE, RE and TEIE bits */
SCI12.SCR.BIT.TIE = 0U;
SCI12.SCR.BIT.TEIE = 0U;
SCI12.SCR.BIT.RIE = 0U;
SCI12.SCR.BIT.TE = 0U;
SCI12.SCR.BIT.RE = 0U;
/* Set RXD12 pin */
MPC.PE2PFS.BYTE = 0x0CU;
PORTE.PMR.BYTE |= 0x04U;
PORTE.PDR.BYTE &= 0xFBU;
/* Set TXD12 pin */
PORTE.PODR.BYTE |= 0x02U;
PORTE.PDR.BYTE |= 0x02U;
MPC.PE1PFS.BYTE = 0x0CU;
PORTE.PMR.BYTE |= 0x02U;
/* Set the clock selection */
SCI12.SCR.BYTE |= _00_SCI_INTERNAL_SCK_UNUSED;
/* Clear the SIMR1.IICM, SPMR.CKPH, and CKPOL bit, and set SPMR */
SCI12.SIMR1.BIT.IICM = 0U;
SCI12.SPMR.BYTE |= _00_SCI_RTS | _00_SCI_CLOCK_NOT_INVERTED | _00_SCI_CLOCK_NOT_DELAYED;
/* Set SMR, SCMR */
SCI12.SMR.BYTE |= _00_SCI_CLOCK_PCLK | _00_SCI_MULTI_PROCESSOR_DISABLE | _00_SCI_STOP_1 | _00_SCI_PARITY_EVEN |
_00_SCI_PARITY_DISABLE | _00_SCI_DATA_LENGTH_8 | _00_SCI_ASYNCHRONOUS_MODE;
SCI12.SCMR.BYTE |= _00_SCI_SERIAL_MODE | _00_SCI_DATA_INVERT_NONE | _00_SCI_DATA_LSB_FIRST;
/* Set SEMR, SNFR */
SCI12.SEMR.BYTE |= _00_SCI_LOW_LEVEL_START_BIT | _00_SCI_NOISE_FILTER_DISABLE | _00_SCI_16_BASE_CLOCK;
/* Set BRR */
SCI12.BRR = 0x09U; //con operating frequency 12MHz 0x09 da' 38400 bit/s (con errore del 2.34%)
}
I cannot touch the serial setting of this mcu I can just modify the setting of the esp32.
The point is to understand which are the settings here…
Do you have experience on that ?
Thanks a lot …
Simone