The input port bit status always returns 0 when queried [SOLVED]

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Sasi
Posts: 91
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 36 times
Been thanked: 9 times

Flowcode v10 The input port bit status always returns 0 when queried [SOLVED]

Post by Sasi »

Hi Martin,

The target processor is PIC18F46K80.
I set the default compiler to XC8 v2.50 so that the UART "SendString" command works.
But it seems that this compiler cannot produce a hex file that the MCU can use to read the current value of a port bit.
The v2.46 and v2.10 compilers produce a working hex file for this purpose.
I have attached the test project.
I would be happy if you could help me.

Regards, Sasi
Port_INPUT_Test_2_NOT Working_with_XC8_v2.50.fcfx
(12.67 KiB) Downloaded 9 times
Last edited by Sasi on Tue Apr 29, 2025 7:25 pm, edited 1 time in total.

medelec35
Matrix Staff
Posts: 1913
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 619 times
Been thanked: 644 times

Re: The input port bit status always returns 0 when queried

Post by medelec35 »

Hello.
It looks like its compiler bug specific to the 18F46K8.
With 18F46K80 & xc2.50 I can confirm the input on D3 is not working.
Using the xc8 that was shipped with Flowcode V10, the input works as expected, but the strings don't work as you have previously stated.
Keeping the compiler version at 2.50, I changed hardware to 16F18877 and 18F47K40 (running at 64MHz) and both work as expected since the output was changing depending on Input on D3.

Still with 18F47K40, changed compiler to the version shipped with Flowcode and testing strings since not working with 18F46K80.

The strings do work.
It seems like the 18F46K8 does have compiler dependent issues.
I would recommend changing target device.
Was there a specific reason for using 18F46K80?
Martin

Sasi
Posts: 91
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 36 times
Been thanked: 9 times

Re: The input port bit status always returns 0 when queried

Post by Sasi »

Thank you very much for trying it out and for your advice.

The situation is that several manufactured boards are in test operation at the customer,
the firmware development of which I completed in mid-December 2024 and I had no problems with these components (Ports, UARTs).
There were problems with the ADC, which was explained by the MCU Errata.
I did the compilation with the default compiler.
I also planned to use the CAN Periphery, whose physical interface is also on the panel, but I would have created the corresponding program module now.
At that time, I experienced that I could no longer compile a flawlessly working program with Flowcode, which had undergone component library updates several times in the meantime.
Unfortunately, I do not remember what version number of component libraries were active on my machine during the last compilation in December.

If you could send me the previous Component libraries that play a role in the operation of the "SendString" command, I would try which one works and return to using the default compiler.

Then we'll see what happens. :roll:

Regards,
Sasi

Sasi
Posts: 91
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 36 times
Been thanked: 9 times

Re: The input port bit status always returns 0 when queried

Post by Sasi »

Hi Martin,

I made the same project with MPLAB X 6.25 as the one I attached in Flowcode.
D3 bit input, D2, D1 bits outputs, the Compiler XC8 v2.50.
It works, so I think the relationship between the Compiler and the PIC18F46K80 processor is fine.
You wrote that the test program written in Flowcode worked with a PIC18F47K40 MCU.
That is, the D3 bit worked in input mode!
For this, the analog mode must be disabled on the given port bit.
The analog mode is enabled and disabled in the case of the PIC18F47K40 with the ANSELx registers as usual,
while in the case of the PIC18F46K80 with the ANCONx registers. The bits in the ANCON register are called ANSELx.

Could this difference be causing the problem?
Sasi
MPLABX_test.jpg
MPLABX_test.jpg (21.39 KiB) Viewed 185 times
PIC18F46K80 PORTD.jpg
PIC18F46K80 PORTD.jpg (23.48 KiB) Viewed 162 times

Sasi
Posts: 91
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 36 times
Been thanked: 9 times

Flowcode v10 Re: The input port bit status always returns 0 when queried

Post by Sasi »

I tested which ANCON1 bit disables the analog input from port D3 (Comparator input)
and it is not ANSEL11 (ANCON1 3rd bit) but ANSEL14 (ANCON1 6th bit). :?
I tested with XC8 v2.50 and v2.46.
PIC18F46K80_ANSEL14_RD3.jpg
PIC18F46K80_ANSEL14_RD3.jpg (6.59 KiB) Viewed 146 times
For me, port C2 did not work as a digital input in the Flowcode project either, if I compiled with XC8 v2.50 but it worked with v2.10 and v2.46.
And there is no analog function on port C2 that should be disabled.

Sasi
Posts: 91
Joined: Wed Dec 02, 2020 12:11 pm
Has thanked: 36 times
Been thanked: 9 times

Re: The input port bit status always returns 0 when queried [SOLVED]

Post by Sasi »

I'm moving to the v2.50 compiler with Basic Optimization.
This modification seems to help.
The optimization modification is described here:
viewtopic.php?p=19683#p19683

Post Reply