PIC18F67K40 UART "SendString" problem (SOLVED)

Moderator: Benj

Post Reply
Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Contact:

PIC18F67K40 UART "SendString" problem (SOLVED)

Post 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
Attachments
PIC18F67K40_UART_Test.fcfx
(8.36 KiB) Downloaded 49 times
Last edited by Lagoda on Thu Oct 03, 2019 7:31 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 14851
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: PIC18F67K40 UART "SendString" problem

Post 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 1587 times

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Contact:

Re: PIC18F67K40 UART "SendString" problem

Post 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 41 times
What should the next step be?

Best Regards,
Lagoda

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Contact:

Re: PIC18F67K40 UART "SendString" problem

Post 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
Attachments
PIC18F67K40_UART_Test_2.fcfx
(11.14 KiB) Downloaded 34 times

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Contact:

Re: PIC18F67K40 UART "SendString" problem

Post 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

stefan.erni
Posts: 570
Joined: Fri Aug 19, 2016 2:09 pm
Location: switzerland
Contact:

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Post 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

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Contact:

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Post 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

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Contact:

Re: PIC18F67K40 UART "SendString" problem (SOLVED)

Post 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

Post Reply