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

Is modbus working with new compiler [SOLVED]
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: 19215

View user's profile Send private message

PostPosted: Fri Aug 18, 2017 1:45 pm     Reply with quote

Well, the biasing is wrong, but presumably the other device has biasing, so is 'saving the day'.

However:
"I can see the RX Led blink when modscan32.exe pings but TX don't.", says that the bus reversal is probably not happening. Given that when you looked you found that there were fuses in the old code, that you had not put in the new, you need to triple check that the actual 'SIG' connection really is connecting to pin C0.
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Thanks Mr T
PostPosted: Fri Aug 18, 2017 1:56 pm     Reply with quote

Thanks Mr T,

Let me pull up the hard disk that I salvaged from my burnt system. Hopefully I would be able to get more information to provide you with.

Good thing that its a weekend.
_________________
Regards,
Devil
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

An addition to my comment
PostPosted: Fri Aug 18, 2017 2:26 pm     Reply with quote

An addition to my comment

I don't remember seeing any warning messages like the one below when I compiled it in the older version. I will try my best to make some time tomorrow and try to get the data recovered Sad

>>> Warning 209 "E:\Program Files (x86)\PICC\Drivers\modbus_phy_layer_rtu.c" Line 100(1,1): Assignment to enum is not of the correct type


Code:
--- Info 300 "E:\Program Files (x86)\PICC\Drivers\modbus_phy_layer_rtu.c" Line 31(1,1): More info:   Timer 2 tick time is 128.00 us
>>> Warning 209 "E:\Program Files (x86)\PICC\Drivers\modbus_phy_layer_rtu.c" Line 100(1,1): Assignment to enum is not of the correct type
>>> Warning 216 "main.c" Line 180(1,2): Interrupts disabled during call to prevent re-entrancy:  (@GETCH_BIU_1)
>>> Warning 216 "main.c" Line 180(1,2): Interrupts disabled during call to prevent re-entrancy:  (modbus_enable_timeout)
>>> Warning 216 "main.c" Line 180(1,2): Interrupts disabled during call to prevent re-entrancy:  (modbus_calc_crc)
      Memory usage:   ROM=26%      RAM=37% - 42%
      0 Errors,  4 Warnings.
Build Successful.

_________________
Regards,
Devil
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Fri Aug 18, 2017 11:00 pm     Reply with quote

That is just a warning.
The new compiler warns if you mix types. It treats an 'enum' as a different type to an integer, so warns about assigning an enum to a number. However this is perfectly legitimate.

Comment.

The listing shows that the code you are compiling now is not the same as the code that was used before. You have sent me a larger part of the listing directly, and this has a capacitive touch pad being setup.
You either need to find the code that corresponds with the working hex file, or sit down with the listing, and go through it, and extract the original code. Then compile _this_.

Currently you have non working code, and are blaming the compiler because this does not work. You need to start from a 'known working' location. There are extra features with the newer Modbus code, but it does work.
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Looks like today is my lucky day
PostPosted: Fri Aug 18, 2017 11:16 pm     Reply with quote

Looks like today is my lucky day, I hooked up the hard disk from my shot OLD machine to the laptop and I was able to retrieve the PICC folder.

Here are the changes I noticed.

1) Modbus.h has some updates in the comments.
2) Modbus.c has some updates relating to Parity.
3) modbus_phy_layer_rtu.c had a fair share of updates to the Parity.
4) The devices .h files have a ton of updates.

So I made a backup of all 4 files mentioned above, and then pasted the files that I had with the older version. But nothing seems to change, I still get the error mentioned in my previous post.


Quote:
An addition to my comment

I don't remember seeing any warning messages like the one below when I compiled it in the older version. I will try my best to make some time tomorrow and try to get the data recovered Sad

>>> Warning 209 "E:\Program Files (x86)\PICC\Drivers\modbus_phy_layer_rtu.c" Line 100(1,1): Assignment to enum is not of the correct type


Changes to Modbus.c


Changes to modbus_phy_layer_rtu.c



Changes to Modbus.h



MR T, The code with the cap touch that I IMed you was just for you to test that code did work in the old compiler pretty well, it was used to turn on the water pumps Manually.. Since I got the data from my OLD hard disk up and running let me see if I can get the old PICC working again.

I will post the udpates.
_________________
Regards,
Devil
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Here is the working LST File from OLD and new.
PostPosted: Fri Aug 18, 2017 11:57 pm     Reply with quote

Quote:
Currently you have non working code, and are blaming the compiler because this does not work. You need to start from a 'known working' location. There are extra features with the newer Modbus code, but it does work.

Definitely not, I did not have the old compiler handy as it was destroyed with my PC. with a very good person spilling his water bottle onto it. I have done my best from the archives that I had. Crying or Very sad Crying or Very sad Crying or Very sad

Moment of truth, I have the old harddisk up and running, got decent amount of data from it.

Here are the old and new .LST and HEX files. I do not know how to attach files so uploaded it to a different website. https://ufile.io/y6oay
Note: The file will be there only for 30 days.
_________________
Regards,
Devil
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 19, 2017 10:31 am     Reply with quote

Regarding your enum() warning, I found that if you change it to the
following, the warning disappears:
Quote:
enum {MODBUS_GETADDY=0, MODBUS_GETFUNC=1, MODBUS_GETDATA=2} modbus_serial_state = MODBUS_GETADDY;

This sets 'modbus_serial_state' to one of the enumerated constants,
instead of setting it to 0. The compiler likes this.


Regarding the two list files, I compared them with ExamDiff.
The first thing I noticed is that in modbus.c for vs. 5.049, the default parity
is EVEN. The default for vs. 4.140 is NONE. So apparently, your
modbus slave must use NO parity. It worked with vs. 4.140.
I suggest that you do a test and disable parity for vs. 5.049, as follows:
Code:

#define MODBUS_PARITY "NONE" // *** Place this line above the #include
#include "modbus.c"   



In the 16F727 errata, it lists an awful silicon bug:
http://ww1.microchip.com/downloads/en/DeviceDoc/80000382K.pdf
Quote:

8. Module: Interrupts

8.1 Stack Push
The interrupt logic incorrectly pushes two
addresses to the stack when vectoring to the
interrupt vector. Specifically, the interrupt vector
address 0x4 is incorrectly pushed to the stack after
the current PC, at the time the interrupt was
received, is pushed. This will cause the stack to
overflow if the user program is operating seven
calls deep when an interrupt arrives
. Because the
stack is circular, the overflow causes the first stack
address to be overwritten.
Work around
Disable interrupts by clearing the GIE bit in the
INTCON register whenever the user program is
operating seven calls deep. This ensures that
interrupts will not cause the stack to overflow.

In your old vs. 4.140, I don't think CCS tries to do anything about this.
But in vs. 5.049, they do add code to compensate for this bug.
I don't know if they did it correctly or not. I didn't analyze it.
I'm mentioning this because it could be an issue.
I would never have selected a PIC that has this bug, and it's present
in all silicon revisions, A7 to AK.
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Thanks PCM Programmer.
PostPosted: Sat Aug 19, 2017 11:19 am     Reply with quote

Thanks PCM Programmer.

Quote:
In the 16F727 errata, it lists an awful silicon bug:
http://ww1.microchip.com/downloads/en/DeviceDoc/80000382K.pdf

ewehhh

Did not think of it at all, was just trying to operate 8 water pumps for my friends farm and able to monitor if its ON or OFF from the 8 locations of the water pumps. Turn the individual water pumps from any of the 8 locations.
Did not think it was such a big task though.

Used 16F727 as it was cheap and its capsense.. You know muddy water + wet hands + cow dung and all the things around dont go well with electronics thought it was a good idea to conceal it and put it somewhere so that nothing affects it, But all the switching on and off would work due to the cap sense touch feature. Laughing
_________________
Regards,
Devil
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 19, 2017 2:40 pm     Reply with quote

You didn't say if it's now working or not.

After fixing the parity issue, does the project work ?
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Tested it just now
PostPosted: Sat Aug 19, 2017 11:30 pm     Reply with quote

Tested it just now and it works.. Cool Cool Cool Cool
Thank you all!!!
_________________
Regards,
Devil
devilfrmheaven



Joined: 09 Feb 2016
Posts: 53

View user's profile Send private message

Thank You PCM
PostPosted: Sun Aug 20, 2017 6:16 am     Reply with quote

Thank You PCM
_________________
Regards,
Devil
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