View previous topic :: View next topic |
Author |
Message |
pebbert9
Joined: 31 Dec 2010 Posts: 39
|
Compiler error with modbus driver |
Posted: Mon Sep 21, 2020 6:24 pm |
|
|
Hello,
I am trying to get this sample code below to compile but it is giving me errors
Using 5.094
*** Error 28 "C:\Program Files (x86)\PICC\Drivers\modbus_phy_layer.h" Line 78(44,45): Expecting an identifier Bad SFR name
*** Error 12 "C:\Program Files (x86)\PICC\Drivers\modbus_phy_layer.h" Line 99(8,11): Undefined identifier
*** Error 48 "C:\Program Files (x86)\PICC\Drivers\modbus_phy_layer.h" Line 99(12,16): Expecting a (
*** Error 48 "C:\Program Files (x86)\PICC\Drivers\modbus_phy_layer.h" Line 99(17,22): Expecting a (
--- Info 300 "C:\Program Files (x86)\PICC\Drivers\modbus_phy_layer_rtu.c" Line 25(1,1): More info: Timer 1 tick time is 128.00 us
*** Error 12 "C:\Program Files (x86)\PICC\Drivers\modbus_phy_layer_rtu.c" Line 317(24,25): Undefined identifier TRMT
Code: | #include <18F25K83.h>
#device ADC=12
#FUSES NOWDT //No Watch Dog Timer
#use delay(clock=32000000,crystal=8000000)
#define MODBUS_BUS SERIAL
#define MODBUS_TYPE MODBUS_TYPE_SLAVE
#define MODBUS_SERIAL_TYPE MODBUS_RTU
#define MODBUS_SERIAL_INT_SOURCE MODBUS_INT_RDA
#define MODBUS_SERIAL_RX_PIN PIN_C6
#define MODBUS_SERIAL_TX_PIN PIN_C4
#define MODBUS_SERIAL_ENABLE_PIN PIN_C5
#define MODBUS_SERIAL_BAUD 115200
#define MODBUS_OUR_ADDRESS 15
#pin_select U1RX=MODBUS_SERIAL_RX_PIN
#pin_select U1TX=MODBUS_SERIAL_TX_PIN
#include "modbus.c"
void main()
{
modbus_init();
while(TRUE)
{
//TODO: User Code
}
} |
Any ideas?
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 22, 2020 12:41 am |
|
|
Substitute this block of code for lines 56 through 107 in the
modbus_phy_layer.h file. This is for CCS vs. 5.095.
It will now compile without errors. These changes may not
be sufficient to make it work, because the UART in the 18F25K83
is significantly different than in the 18F46K22. But at least it
will now compile.
Code: |
#if (MODBUS_SERIAL_INT_SOURCE != MODBUS_INT_EXT)
#if defined(__PCD__)
#if (MODBUS_SERIAL_INT_SOURCE == MODBUS_INT_RDA)
#word TXSTA=getenv("SFR:U1STA")
#bit TRMT=TXSTA.8
#elif (MODBUS_SERIAL_INT_SOURCE == MODBUS_INT_RDA2)
#word TXSTA=getenv("SFR:U2STA")
#bit TRMT=TXSTA.8
#elif (MODBUS_SERIAL_INT_SOURCE == MODBUS_INT_RDA3)
#word TXSTA=getenv("SFR:U3STA")
#bit TRMT=TXSTA.8
#elif (MODBUS_SERIAL_INT_SOURCE == MODBUS_INT_RDA4)
#word TXSTA=getenv("SFR:U4STA")
#bit TRMT=TXSTA.8
#endif
#else
#if (MODBUS_SERIAL_INT_SOURCE == MODBUS_INT_RDA)
#if getenv("sfr_valid:U1ERRIR") // *** Add this line ***
#byte TXSTA=getenv("sfr:U1ERRIR") // *** Add this line ***
#elif getenv("sfr_valid:TXSTA") // *** Change to #elif ***
#byte TXSTA=getenv("sfr:TXSTA")
#elif getenv("sfr_valid:TXSTA1")
#byte TXSTA=getenv("sfr:TXSTA1")
#else
#byte TXSTA=getenv("sfr:TX1STA")
#endif
#elif (MODBUS_SERIAL_INT_SOURCE == MODBUS_INT_RDA2)
#if getenv("sfr_valid:TXSTA2")
#byte TXSTA=getenv("sfr:TXSTA2")
#else
#byte TXSTA=getenv("sfr:TX2STA")
#endif
#elif (MODBUS_SERIAL_INT_SOURCE == MODBUS_INT_RDA3)
#if getenv("sfr_valid:TXSTA3")
#byte TXSTA=getenv("sfr:TXSTA3")
#else
#byte TXSTA=getenv("sfr:TX3STA")
#endif
#elif (MODBUS_SERIAL_INT_SOURCE == MODBUS_INT_RDA4)
#if getenv("sfr_valid:TXSTA4")
#byte TXSTA=getenv("sfr:TXSTA4")
#else
#byte TXSTA=getenv("sfr:TX4STA")
#endif
#endif
#if getenv("sfr_valid:U1ERRIR") // *** Add this line ***
#bit TRMT=TXSTA.7 // *** Add this line ***
#else // *** Add this line ***
#bit TRMT=TXSTA.1
#endif // *** Add this line ***
#endif
#endif
|
|
|
|
pebbert9
Joined: 31 Dec 2010 Posts: 39
|
|
Posted: Tue Sep 22, 2020 11:09 am |
|
|
Thanks for your help.
The 18F25K83 does appear to be working now. |
|
|
|