Page 4 of 4

Re: PIC as MODBUS slave

Posted: Mon Aug 14, 2017 11:20 am
by Benj
Hello,

I think the problem causing the compilation error is the Flowcode project file name, it's been reported before. Try shortening the name and getting rid of the brackets.
viewtopic.php?f=63&t=17965&p=76175#p76151

Re: PIC as MODBUS slave

Posted: Mon Aug 14, 2017 10:39 pm
by SILVESTROS9
Hello,
Thanks for info. I give a short FC project file name (MBSlaveLCD16.fcfx) , compiler gives me the following , no data at lcd when I send some characters ( emulator gives me response error). LCD works fine when I change the MCU with a PIC16F1939(with the same code).

Launching the compiler...
C:\Program Files (x86)\Flowcode 7\compilers\pic\bin\xc8.exe --chip=18F458 "MBSlaveLCD16.c" --MSGDISABLE=359,1273,1388
Microchip MPLAB XC8 C Compiler (Free Mode) V1.38
Build date: Jun 30 2016
Part Support Version: 1.38
Copyright (C) 2016 Microchip Technology Inc.
License type: Node Configuration
Employing 18F458 errata work-arounds:
* Address 4000h boundary
* Faulty table reads at -40 degrees C
* GOTO instruction at reset vector must be preceded by NOP
* Peripherals can misbehave if BSR = 15
* DAW instruction may improperly clear CARRY bit
* Writes to flash must target opposite side of 4000h boundary
MBSlaveLCD16.c:
37: __config("__PROG_CONFIG", "pic18", 0x3, 0xFFFF);
^ (0) Can't find config word 3 used in in __PROG_CONFIG() (warning)

Are configuration settings correct? Below I post the file . Thanks.

Re: PIC as MODBUS slave

Posted: Tue Aug 15, 2017 11:34 am
by Benj
Hello,

To sanity check your configuration settings use the 1 second flasher method, it works really well and is a nice double check that everything is right. I cannot really double check your config settings are valid without knowing the details of your hardware.

It looks to me from your project like you have a 16MHz crystal connected to the oscillator pins. The other config settings look fine though the power up timer can be useful if you want to enable this.
37: __config("__PROG_CONFIG", "pic18", 0x3, 0xFFFF);
^ (0) Can't find config word 3 used in in __PROG_CONFIG() (warning)
This can be safely ignored.

The other warnings are just telling you about workarounds the compiler is doing to get around known problems with the silicone.

Re: PIC as MODBUS slave

Posted: Wed Aug 16, 2017 7:06 pm
by SILVESTROS9
Making some tests with flasher method , I note that the code with PIC18F458 don't start and therefore not run , while with PIC16F1939 works fine , I don't know why. Is there an error at code , or hardware needs modification? Hardware is simple , I don't think that there is a reason for modification . Is there a way to check the code for errors? Below I post a sketch of schematic for your opinion.

Re: PIC as MODBUS slave

Posted: Thu Aug 17, 2017 12:44 pm
by Benj
Hello,

From your schematic it looks like you're missing a resistor between pin 1 of the micro and VCC to pull the MCLR/Reset pin high. A value in the range of 1K to 100K should work well.

The 16F1937 has a configuration option for internal MCLR but the 18F458 does not which maybe explains the difference.

Re: PIC as MODBUS slave

Posted: Thu Aug 17, 2017 7:59 pm
by SILVESTROS9
I connect a pull-up resistor 10K between pin1 and VDD , so the mcu works fine . Many thanks Ben !