Frame length error - Modbus RTU slave

Hi

I have configured my project to have a Modbus RTU slave on UART1. When I poll the dev kit, using Modscan, I get frame length errors. I have checked baud rate and parity. My board connects to my PC using an rS485 line driver (I don't think this is the problem).

Any suggestions.

Regards Mark

  • Hi Mark,

    There is not much to go on here, to be honest. Also, Nordic does not provide Modbus support directly (though I see there are Modbus libraries in Zephyr). Assuming you use that I suggest you describe the issue you are seeing and what you have find by debugging in more detail, and hopefully you will get feedback from the Zephyr community.

    Einar

  • Hi

    Yes I am using the Zephyr Modbus module.

    I have put a line analyser on the input pin for Modbus UART and verified that a good frame is being presented to the development kit. I am still getting frame length errors. The UART is configured for 19200 bps operation. My console UARTs seem to work OK, suggesting that the core clock configuration is OK.

    Regards Mark

  • I have configured the project to implement a simple UART and not the Modbus module. I have verified that the frame is coming in ....

    but it seems to come in a character at a time i.e. each time I receive a character I get an interrupt and the character is handled individually. It is as though the driver doesn't tolerate contiguous characters. So I don't get a complete message in the FIFO.

    Is there something I am missing in the UART configuration ?

    Regards Mark

  • Hi Mark,

    Mark Payne said:
    Is there something I am missing in the UART configuration ?

    That could be. How have you configured / implemented UART communication on the nRF side? It is certainly possible to configure single byte transactions, but the UARTE peripheral does have DMA and allows long transactions without CPU involvements.

  • Hi Einar

    I configured the UART in the boards dts file:

    &uart1 {
        status = "okay";
        compatible = "nordic,nrf-uarte";
        current-speed = <19200>;
        tx-pin = <40>;
        rx-pin = <38>;
    };

    However, I have now managed to get the Modbus driver to work by hard coding the UART configuration in modbus_serial.c.

    /*TODO remove following hard configuration */
        uart_cfg.baudrate    = 19200;
        uart_cfg.parity        = UART_CFG_PARITY_NONE;
        uart_cfg.stop_bits    = UART_CFG_STOP_BITS_1;
        uart_cfg.data_bits    = UART_CFG_DATA_BITS_8;
        uart_cfg.flow_ctrl    = UART_CFG_FLOW_CTRL_NONE;
        
        if (uart_configure(cfg->dev, &uart_cfg) != 0) {

    The only thing I can think of is the original code is setting the Modbus comms to something I don't want. I will look into this and if I find something I will post you.

    For now, thanks for your help.

    Regards Mark

Related