CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

18f4520 working modbus don't work on 18f46k22
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 16935

View user's profile Send private message

PostPosted: Sat Feb 20, 2021 12:55 pm     Reply with quote

Yes, those are only warnings. Caused because the modbus code calls the
CRC calculation functions both inside and outside the interrupt.

Now this means the PIC code is accepting the incoming data request.
So has to be accepting this and it's checksum.
It is then replying. So serial RX and TX have to be working.
What is failing is that the PC code is saying the packet checksum is wrong.
Suspect one will have to dismantle the packet and calculate the check
oneself and see what is wrong.
temtronic



Joined: 01 Jul 2010
Posts: 7975
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Feb 20, 2021 1:36 pm     Reply with quote

What's very odd is that it works using the 4520 PIC and not the 46K22. Since all the modbus stuff, like CRC, is in the 'modbus.c' file and the hardware (RS485) is the same, it's hard to understand what is causing the problem...
Ttelmah



Joined: 11 Mar 2010
Posts: 16935

View user's profile Send private message

PostPosted: Sun Feb 21, 2021 3:03 am     Reply with quote

Question.
Was the 'working' 4520 code, compiled with the same compiler version?.
I ask, because I don't have 5.076. Now this is potentially interesting, because
as compiler versions come along, I don't save them, when I have had
significant 'issues' with a version. The fact that I didn't save 5.076, means
that for me, it had some significant issue(s).
Looking at the data packet shown, the checksum is wrong, so the PC
is reporting correctly. The data looks completely correct except for the
checksum. So I'm going to take a little while and generate the same
packet, and try putting this through the checksum calculation on 5.078,
and see if I get the result being shown here. If not, then it implies there
is some fault in the arithmetic on this compiler version.
Will come back when I have done this. Smile
Ttelmah



Joined: 11 Mar 2010
Posts: 16935

View user's profile Send private message

PostPosted: Sun Feb 21, 2021 3:46 am     Reply with quote

Looking at it, something very odd is going on with his compiler version.
If you look, the code as posted has 0x1D 05 loaded into the bottom holding
register, but the reply being shown has 00 01 being sent for this.
I've changed what is loaded to the holding registers to match what he
shows being sent, then run the code compiled with 5.078, and this generates
the CRC as D8FC, not the DF08 he has. I then tried again with 5.075, and this
too gives the right CRC. A look at the 'compiler changes' list shows that
5.076, had a bug with the -- operator on certain types of variable,
fixed in 5.077 I'd suspect the modbus code is actually being damaged by this
fault.
This was obviously 'why' I did not keep this version.... Sad
D8FC is the correct checksum for the data shown.

So the reason it is failing is that he has a compiler issue.
yvzd



Joined: 16 Feb 2021
Posts: 9

View user's profile Send private message Send e-mail

PostPosted: Sun Feb 21, 2021 6:31 am     Reply with quote

Ttelmah wrote:
Looking at it, something very odd is going on with his compiler version.
If you look, the code as posted has 0x1D 05 loaded into the bottom holding
register, but the reply being shown has 00 01 being sent for this.
I've changed what is loaded to the holding registers to match what he
shows being sent, then run the code compiled with 5.078, and this generates
the CRC as D8FC, not the DF08 he has. I then tried again with 5.075, and this
too gives the right CRC. A look at the 'compiler changes' list shows that
5.076, had a bug with the -- operator on certain types of variable,
fixed in 5.077 I'd suspect the modbus code is actually being damaged by this
fault.
This was obviously 'why' I did not keep this version.... Sad
D8FC is the correct checksum for the data shown.

So the reason it is failing is that he has a compiler issue.


Dear Ttelmah and also other friends thanks a lot for your valuable help. As you point out to compiler I try 5.092 and guess what Smile everything is ok now crc calculation is right now.

Thak you all again for your valuable help I am so happy now Smile

Ttelmah



Joined: 11 Mar 2010
Posts: 16935

View user's profile Send private message

PostPosted: Sun Feb 21, 2021 7:27 am     Reply with quote

Very Happy

You can also see 'why' we often have to ask for people to give the compiler
version. You nicely did, so I 'went looking' to see if there might be a compiler
issue. Sadly there was... Sad

Glad you have it working now.
temtronic



Joined: 01 Jul 2010
Posts: 7975
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Feb 21, 2021 8:52 am     Reply with quote

He must have updated the compiler between the 4520 working and 46k22 not working ??
Ttelmah



Joined: 11 Mar 2010
Posts: 16935

View user's profile Send private message

PostPosted: Sun Feb 21, 2021 12:00 pm     Reply with quote

That's why I asked:
Quote:

Was the 'working' 4520 code, compiled with the same compiler version?.

The problem didn't exist on the previous version, and was fixed on the
next one....
yvzd



Joined: 16 Feb 2021
Posts: 9

View user's profile Send private message Send e-mail

PostPosted: Sun Feb 21, 2021 12:30 pm     Reply with quote

Ttelmah wrote:
Very Happy

You can also see 'why' we often have to ask for people to give the compiler
version. You nicely did, so I 'went looking' to see if there might be a compiler
issue. Sadly there was... Sad

Glad you have it working now.



Dear Ttelmah thank you so much again Smile yes normally I don't want to change version because I managed some header files according to my easypic board (like lcd) but I had another laptop for free so when I tried on it ohh thanks got Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group