Page 1 of 1

ERROR IN PIC16F1709 CODE

Posted: Wed Jun 12, 2019 12:07 pm
by SILVESTROS9
Hello to all....
I was loaded a working code with PIC16F1939 that displays chars on a 4x20LCD, to a smaller pcb using a PIC16F1709....the code runs, but have no chars on LCD and get an error "invalid checksum"....where is the problem? at FC7 code , or at programmer ? my programmer is PICkit2 with modified .dat file (PK2Devicefile-1.62.14), to support PIC16F1709...

ERROR IN PIC16F1709 CODE

Posted: Wed Jun 12, 2019 12:16 pm
by SILVESTROS9
below are the schematic and the code...the project is to send chars with a Modbus master (a PLC) , to a 4x20 lcd..

Re: ERROR IN PIC16F1709 CODE

Posted: Wed Jun 12, 2019 12:20 pm
by LeighM
Maybe in the conversion from PIC16F1939 to PIC16F1709 you have missed something, clock configs etc?
As often suggested, have you tried a simple LED or output toggle to check the code through to programming of the new PIC16F1709 board is correct?

Re: ERROR IN PIC16F1709 CODE

Posted: Wed Jun 12, 2019 3:35 pm
by LeighM
Hi,
In the config settings you have HS Osc and x4 PLL
I presume you have an external 16MHz crystal?
With those settings you will need to set the Clock Speed in the General Options to 64MHz to get the correct UART baud rate

Re: ERROR IN PIC16F1709 CODE

Posted: Wed Jun 12, 2019 3:44 pm
by Benj
Hello,

I do bang on about the one second flasher but this will help to save yourself from these types of headaches time and time again.
https://www.matrixtsl.com/wiki/index.ph ... ED_flasher

Re: ERROR IN PIC16F1709 CODE

Posted: Wed Jun 12, 2019 7:30 pm
by SILVESTROS9
I made the flasher test...not work....Ι would like to use use INTOSC ....what is the proper fosc.? what is the proper config? the test was with HS osc.config and 16MHZ fosc.

Re: ERROR IN PIC16F1709 CODE

Posted: Wed Jun 12, 2019 8:51 pm
by medelec35
Running with internal osc at 16MHz, you will to:
Disable PLL
Within Build, Project options change the osc type from HS (that is for an external crystal or resonator above 4MHz) to Intosc.
Place a C code icon at the very start,before the main loop.
Within the C code icon add

Code: Select all

OSCCON = 0x78;

Re: ERROR IN PIC16F1709 CODE

Posted: Wed Jun 12, 2019 11:35 pm
by SILVESTROS9
update....after config changes (thanks medelec35), the code runs (flash test ok), but no chars on LCD....The same communication error.."invalid checksum in response "...a hardware damage at SN75176 maybe ? it seems that there is no valid response code....line10 below...response code : no slave address (01d), no function code (16d), no data address of the first register(001d).....very strange..the code works fine with PIC16F1939....NOTE : pickit2 not support PIC16F1709....I use an updated .dat with some extra chip....maybe there is a problem with that ?

01:01:46.626: ===========================[Serial Port Setup]=========================================
01:01:46.629: Com5, Baud Rate: 9600, Data Bits: 8 Bits, Parity: None, Stop Bits: 1 Stop Bit
01:01:46.631: Echoback: Off, RTS Control: Off, Transmit Delay: 5 ms, Response Delay: 600 ms
01:01:46.634: =======================================================================================
01:01:46.644: Write Holding Register(s)
01:01:46.647: Device Address: 1d, Register: 1d, Number of Registers: 10
01:01:46.649: |-> Write Register: 1d, Number of Registers : 10
01:01:46.658: -> [001d] [016d] [000d] [001d] [000d] [010d] [020d] [000d] [127d] [000d] [068d] [000d] [100d] [000d] [051d] [000d] [065d] [000d] [084d] [000d] [083d] [000d] [073d] [000d] [083d] [000d] [032d] [163d] [068d]
01:01:46.681: <- [255d] [255d] [255d] [001d] [255d] [055d] [187d] [125d] [255d] [089d]
01:01:46.683: Error > Invalid checksum in response.