2400511_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2400511_en-US

2400511_en-US

Modbus RTU communication error

I am writing code for MC9S08JM60 to read MODBUS RTU holding registers. I am reading 15 holding registers which gives me a 35 byte frame. So i am expected to get 1 interrupt for each byte but i am getting 1 interrupt for the first byte of the frame and next interrupt is for the first byte of the next frame. So I am losing the rest 34 bytes. Please provide any input for this.

I am attaching my code snippets.

Re: Modbus RTU communication error

Hi @An95 

Thank you for your post!

There is any documentation of Modbus RTU with the S08.

But the issue you are facing could be related to not clear the RDRF.

The RDRF (Receive Data Register Full) flag is cleared only by reading SCI1D after reading SCI1S1. If SCI1D is not read in the ISR, the interrupt fires once and then the receiver stalls.

Refer to 14.2.4 SCI Status Register 1 (SCIxS1) of the MC9S08JM60 Series Data Sheet.

Make sure your code is clearing the flag correctly.

BR

Re: Modbus RTU communication error

Hi @carlos_o ,

Thank you for your response.
The RDRF flag is cleared when it enters the callback function of the interrupt service routine. The 35 byte frame is coming in a single interrupt. If I take a buffer of 35 bytes even then i am not able to read the whole frame.
Please share your input regarding this.
BR

Re: Modbus RTU communication error

I have changed my implementation to bare metal code still i am receiving only 1 byte.
Please share any input.

Re: Modbus RTU communication error

Hi @An95 

The SCI only could receive 1 byte each time RDRF is trigger. So, you will need to trigger 35 interrupts to read the 35 bytes you are sending. 

You could refer to the chapter 14.3.3 Receiver Functional Description

The SCI module only has one SCI Data Register (SCIxD) that could save 8 bits each time. 

Tags (1)
No ratings
Version history
Last update:
yesterday
Updated by: