|
|
View previous topic :: View next topic |
Author |
Message |
hugo_br
Joined: 01 Aug 2011 Posts: 26 Location: BRAZIL
|
Problem if MODBUS.C if PIC16F1938. |
Posted: Fri Aug 16, 2013 10:19 am |
|
|
Good morning.
I'm trying to implement a Modbus / RS485 routine to control an inverter LS. However I am having several problems with the drive modbus.c that comes with CCS v5.011. I would simply call the functions and work. But to my surprise not compiled.
I'm using a PIC16F1938. And every time I have a different problem and does not compile.
Here is a piece of the program:
Code: |
#include "modbus.c"
#include <16F1938.h>
#fuses hs,mclr,intrc_io,wdt,protect,put,brownout,nolvp,nocpd,nowrt,borv25
#use delay(clock=16000000, RESTART_WDT)
#define MODBUS_PROTOCOL MODBUS_PROTOCOL_SERIAL
#define MODBUS_TYPE MODBUS_TYPE_MASTER
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#define MODBUS_SERIAL_TYPE MODBUS_RTU //use MODBUS_ASCII for ASCII mode
#define MODBUS_SERIAL_BAUD 9600
#define MODBUS_SERIAL_TX_PIN PIN_C6 // Data transmit pin
#define MODBUS_SERIAL_RX_PIN PIN_C7 // Data receive pin
#define MODBUS_SERIAL_ENABLE_PIN PIN_A1 // Controls DE pin for RS485
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
//#define MODBUS_SERIAL_RX_ENABLE 0 // Controls RE pin for RS485
#define MODBUS_SLAVE_ADDRESS 0x1
|
I do not know what else to do, I've done all the tips passed here in the forum and nothing worked, when trying to compile the following message appears:
Code: |
*** Error 128 "C:\Program Files (x86)\PICC\Drivers\modbus_phy_layer.h" Line 75(14,18): A #DEVICE required before this line
1 Errors, 0 Warnings.
Build Failed.
|
Could anyone give help, I really need to continue this project.
Thank you very much. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 16, 2013 11:09 am |
|
|
Quote: | #include "modbus.c"
#include <16F1938.h>
#fuses hs,mclr,intrc_io,wdt,protect,put,brownout,nolvp,nocpd,nowrt,borv25
#use delay(clock=16000000, RESTART_WDT)
#define MODBUS_PROTOCOL MODBUS_PROTOCOL_SERIAL
.
.
.
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
//#define MODBUS_SERIAL_RX_ENABLE 0 // Controls RE pin for RS485
#define MODBUS_SLAVE_ADDRESS 0x1
|
Look at one of the CCS Modbus examples. Look at the order of the
above statements within the file. Look at which line comes first, then
which line comes next, etc. Where does the #include for the PIC go ?
Where does the #include for modbus.c go ? You have been on the
forum for two years. You know how to put together a CCS program.
CCS example program:
Quote: | c:\program files\picc\examples\ex_modbus_master.c |
|
|
|
hugo_br
Joined: 01 Aug 2011 Posts: 26 Location: BRAZIL
|
|
Posted: Fri Aug 16, 2013 11:35 am |
|
|
Good afternoon PCM programmer.
I did exactly as in the example and it still fails, error also occurs. Compiled to use the PIC16F877. I did not put anything out of order and still does not compile. When I change the order of the command line only changes the type of error and does not compile the program.
Using the example that accompanies the CCS error that appears is:
*** Error 44 "C:\Program Files (x86)\PICC\Drivers\modbus_phy_layer_rtu.c" Line 25(9,47): Internal Error - Contact CCS PPUSE
1 Errors, 0 Warnings.
Build Failed.
I never had problems with orders from command lines in CCS, always tried to follow the standards. I'm having problems trying to use these libraries demonstration.
I will be very grateful for any help.
Again thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 16, 2013 12:01 pm |
|
|
I took your posted code and changed the order of the lines to be the
same as in ex_modbus_master.c, and I compiled it with vs. 5.011,
and it compiled with no errors:
Quote: |
Executing: "C:\Program Files\PICC\Ccsc.exe" +FM "pcm_test.c" +DF +LY +T +A +M -Z +Y=9 #__16F1938=TRUE
--- Info 300 "C:\Program Files\PICC\drivers\modbus_phy_layer_rtu.c" Line 25(1,1): More info: Timer 1 tick time is 128.00 us
Loaded C:\Program Files\PICC\Projects\PCM_Test\pcm_test.cof.
BUILD SUCCEEDED: Fri Aug 16 11:01:10 2013 |
Re-arranged program:
Code: |
#include <16F1938.h>
#fuses hs,mclr,intrc_io,wdt,protect,put,brownout,nolvp,nocpd,nowrt,borv25
#use delay(clock=16000000, RESTART_WDT)
#define MODBUS_PROTOCOL MODBUS_PROTOCOL_SERIAL
#define MODBUS_TYPE MODBUS_TYPE_MASTER
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#define MODBUS_SERIAL_TYPE MODBUS_RTU //use MODBUS_ASCII for ASCII mode
#define MODBUS_SERIAL_BAUD 9600
#define MODBUS_SERIAL_TX_PIN PIN_C6 // Data transmit pin
#define MODBUS_SERIAL_RX_PIN PIN_C7 // Data receive pin
#define MODBUS_SERIAL_ENABLE_PIN PIN_A1 // Controls DE pin for RS485
#define MODBUS_SERIAL_RX_BUFFER_SIZE 64
//#define MODBUS_SERIAL_RX_ENABLE 0 // Controls RE pin for RS485
#define MODBUS_SLAVE_ADDRESS 0x1
#include "modbus.c"
void main()
{
while(1);
} |
|
|
|
hugo_br
Joined: 01 Aug 2011 Posts: 26 Location: BRAZIL
|
|
Posted: Fri Aug 16, 2013 1:13 pm |
|
|
Good afternoon again.
I'm not really lucky in this beginning of project. I uninstalled all the CCS, reinstalled again, I got to completely erase the directory PICC. I copied the routine exactly as sent, compiled again and made the same mistake before.
I can not understand this kind of thing, escapes my comprehension.
Would any configuration in CCS that blocks the code at compile time?
Once again I thank the attention and if by chance you have any other tips I again thank you.
Thank you, Hugo. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Aug 16, 2013 2:13 pm |
|
|
Post the latest compiler error message that you get. If the error message
refers to a line number in a file, post the code on that line. Also post
a few lines above and below it. And mark the line that is actually listed
as causing the error. |
|
|
hugo_br
Joined: 01 Aug 2011 Posts: 26 Location: BRAZIL
|
|
Posted: Mon Aug 19, 2013 12:45 pm |
|
|
Good afternoon PCM programmer.
I managed to compile.
I deleted all CCS from my PC and reinstalled my old CCS 4114. A routine compiled normally, without problems.
I apologize for not answered before because I was traveling. I'll make the routine using this old CCS and see how it will port.
If I have any questions I will return to more contact.
I appreciate the attention.
Hugo. |
|
|
|
|
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
|