Page 1 of 1

PIC18F67K40 UART "SendString" problem (SOLVED)

Posted: Thu Sep 26, 2019 10:16 pm
by Lagoda
Hi Ben,

I found a bug while testing the UART Component Macro on CLICKER 2 board.
The "SendString" function does not work, it is not executed.
The "SendNumber" and "SendChar" are working perfectly.
PIC18F67K40_UART_Test_OUTPUT.png
(50.89 KiB) Downloaded 1524 times
3 milliseconds pause between UART TX bursts is it possible that another bug?

Best Regards,

Lagoda

Re: PIC18F67K40 UART "SendString" problem

Posted: Fri Sep 27, 2019 4:56 pm
by Benj
Hi Lagoda,

On 18F devices the extended CPU config setting can cause problems with strings, however looking at your config settings it looks like this is already set to disabled. Maybe try enabling the setting just in case it's been inverted?

What happens if you load the string constant into a string variable using a calculation icon and then send the string variable?

Looking at the code behind the functon it all seems to check out and makes the same UART calls as the SendNumber and SendChar.
SendString.jpg
SendString.jpg (60.86 KiB) Viewed 4843 times

Re: PIC18F67K40 UART "SendString" problem

Posted: Mon Sep 30, 2019 10:14 am
by Lagoda
Hello Ben,

I tried what you wrote.
On 18F devices the extended CPU config setting can cause problems with strings, however looking at your config settings it looks like this is already set to disabled. Maybe try enabling the setting just in case it's been inverted?
After enabling, I get an error message from the compiler:

PIC18F67K40_UART_Test_2.c:
33: __config("__PROG_CONFIG", "pic18", 0x2, 0x7FFF);
^ (1504) the PIC18 extended instruction set was enabled but is not supported by this compiler
(908) exit status = 1
(908) exit status = 1

Error returned from [xc8.exe]

C:\Program Files (x86)\Flowcode\Common\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1
What happens if you load the string constant into a string variable using a calculation icon and then send the string variable?
The situation remains the same. The string variable value does not move the UART TX output.
PIC18F67K40_UART_Test_3.fcfx
(8.89 KiB) Downloaded 208 times
What should the next step be?

Best Regards,
Lagoda

Re: PIC18F67K40 UART "SendString" problem

Posted: Wed Oct 02, 2019 10:20 am
by Lagoda
Hi Ben,

I did another test.
I wanted to copy a string type constant into a string type variable.
Then I convert the string variable to a byte vector and send the elements of the byte vector to the UART buffer.
This works great in the simulator, but don't work in the target circuit.

During debugging, I noticed that the string-type constans value was not copied to the string-type variable.
PIC18F67K40_test.png
(23.64 KiB) Downloaded 1435 times
Debugg_on the targetcircuit.png
(31.26 KiB) Downloaded 1442 times

Thus, the string variable length will be 0 and no data will be added to the UART buffer.

Have you any idea?
Best Regards,
Lagoda

Re: PIC18F67K40 UART "SendString" problem

Posted: Thu Oct 03, 2019 7:29 pm
by Lagoda
Hi Ben,

I found the cause of the error: The MCU what I use comes from Device Revision Id = 0 series.
If the Device Revision Id = 3, the String operations will be executed correctly.

The solution is in this topic:
viewtopic.php?f=76&t=20479

By inserting Code C, the test program works. :D
PIC18F67K40_test_OK.png
(19.89 KiB) Downloaded 1397 times
Could you speed up the execution speed of the "SendNumber" function a bit?
If I count correctly, it performs about 13,500 instruction cycles before sending a three-digit number to UART. :shock:
Can this be reduced?
Best Regards,

Lagoda

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Posted: Fri Oct 04, 2019 7:47 am
by stefan.erni
Hi Lagoda

Well, you have found the mistake.

There is also a Clicker 2 with a PIC32MZ on 200Mhz. With which software did you do the test? Looks very good.

https://www.mikroe.com/clicker-2-for-pic32mz

regards

Stefan

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Posted: Fri Oct 04, 2019 9:39 am
by Lagoda
Hi Stefan,

For register level debugging, I use MPLAB X IDE (v5.20) with PICKIT4 debugger.
I use v1.45 from XC8 compiler because Flowcode8 also uses this by default.
There is also a Clicker 2 with a PIC32MZ on 200Mhz.
I also like this board. It would be nice if the card had an external power connector. Because the battery can only be charged via USB
But perhaps such a connector is missing only for me from the Clicker2 board. :)

Regards,

Lagoda

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Posted: Fri Oct 04, 2019 6:25 pm
by Lagoda
Hi Stefan,

Maybe you didn't mean MPLAB X? :) Sorry!
With which software did you do the test? Looks very good.
If you were thinking of a picture attached to the first post, it is the user interface of a TechTools DV518 Logic Analyzer.
https://www.tech-tools.com/DV518-logic-analyzer.htm

Regards,
Lagoda