PIC18F67K40 UART "SendString" problem (SOLVED)

Moderator: Benj

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

PIC18F67K40 UART "SendString" problem (SOLVED)

Postby Lagoda » Thu Sep 26, 2019 10:16 pm

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
PIC18F67K40_UART_Test_OUTPUT.png (50.89 KiB) Viewed 1118 times

3 milliseconds pause between UART TX bursts is it possible that another bug?

Best Regards,

Lagoda
Attachments
PIC18F67K40_UART_Test.fcfx
(8.36 KiB) Downloaded 31 times
Last edited by Lagoda on Thu Oct 03, 2019 7:31 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 14655
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4644 times
Been thanked: 4266 times
Contact:

Re: PIC18F67K40 UART "SendString" problem

Postby Benj » Fri Sep 27, 2019 4:56 pm

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 1100 times
These users thanked the author Benj for the post:
Lagoda (Mon Sep 30, 2019 9:01 am)
Rating: 5%
 

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: PIC18F67K40 UART "SendString" problem

Postby Lagoda » Mon Sep 30, 2019 10:14 am

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 24 times

What should the next step be?

Best Regards,
Lagoda

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: PIC18F67K40 UART "SendString" problem

Postby Lagoda » Wed Oct 02, 2019 10:20 am

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
PIC18F67K40_test.png (23.65 KiB) Viewed 1029 times

Debugg_on the targetcircuit.png
Debugg_on the targetcircuit.png (31.27 KiB) Viewed 1036 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
Attachments
PIC18F67K40_UART_Test_2.fcfx
(11.14 KiB) Downloaded 20 times

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: PIC18F67K40 UART "SendString" problem

Postby Lagoda » Thu Oct 03, 2019 7:29 pm

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
PIC18F67K40_test_OK.png (19.89 KiB) Viewed 991 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
These users thanked the author Lagoda for the post:
Benj (Fri Oct 04, 2019 10:18 am)
Rating: 5%
 

stefan.erni
Posts: 553
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Has thanked: 173 times
Been thanked: 160 times
Contact:

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Postby stefan.erni » Fri Oct 04, 2019 7:47 am

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

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Postby Lagoda » Fri Oct 04, 2019 9:39 am

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

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Postby Lagoda » Fri Oct 04, 2019 6:25 pm

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
These users thanked the author Lagoda for the post:
stefan.erni (Thu Oct 10, 2019 8:35 am)
Rating: 5%