Page 1 of 1

[WORKAROUND] 16F18877 port IO has something weird going on..

Posted: Sun May 28, 2017 9:48 pm
by EtsDriver
Hi!

I tried to read PORTB/D/E and confirmed that they have +5V on the pins, but it seems that flowcode is returning always zero, no matter what is the ports real state (tested with couple of boards and checked all soldering joints under micros-scope).

Had no chance to check other ports as the chip is on the real hw and there are so many pulldowns installed... But ill order the DIL one's for next week to check it out on EB006-09...

OR if i have something wrong in config and you spot it, please let me know :lol:

Re: 16F18877 port IO has something weird going on...

Posted: Mon May 29, 2017 6:19 am
by bernoulli
Your code has the program operating through the NO side of the decision tree every time. The variable 'read' is not declared, so the program flow is only through the NO side.

Re: 16F18877 port IO has something weird going on...

Posted: Mon May 29, 2017 10:44 am
by medelec35
Hi bernoulli,
bernoulli wrote:The variable 'read' is not declared
That is not correct.
The Decision branch is using a constant called

Code: Select all

Read
which is set to 1, therefore will always be true.
EtsDriver should see

Code: Select all

ALL PORTS READ RESULTS:
via UART, on his monitor.
Along with all the other UART string messages and results.
This should indicate hardware is running at the correct speed and the true part of decision branch is being accessed.

@EtsDriver , have you tried a 1 sec flash test to see if you can turn output on and off?

Martin

Re: 16F18877 port IO has something weird going on...

Posted: Mon May 29, 2017 11:25 am
by Kenrix2
PORTx reads when it's ANSELx bits are set will always return a zero.

Re: 16F18877 port IO has something weird going on...

Posted: Mon May 29, 2017 2:53 pm
by EtsDriver
medelec35 wrote: @EtsDriver , have you tried a 1 sec flash test to see if you can turn output on and off?

Martin
Tested it yes, the outputs can be toggled fine. (And the UART works fine :) )
Kenrix2 wrote:PORTx reads when it's ANSELx bits are set will always return a zero.
EtsDriver wrote:Can you explain that more?
Oh found it:

Had to put C-code that Kenrix2 suggested to all read functions to get them work correctly.
now it works thanks.PNG
(2.62 KiB) Downloaded 2939 times

Code: Select all

ANSELx=0x00 ;
where x is your port you want to use as digital I/O and you can change the value accordingly by what pins you want to use as analog input.
Microchip wrote:12.4.2 DIRECTION CONTROL
12.8.6 ANALOG CONTROL
The ANSELC register (Register 12-25) is used to
configure the Input mode of an I/O pin to analog.
Setting the appropriate ANSELC bit high will cause all
digital reads on the pin to be read as ‘0’ and allow
analog functions on the pin to operate correctly.
The state of the ANSELC bits has no effect on digital output
functions. A pin with TRIS clear and ANSELC set will
still operate as a digital output, but the Input mode will be
analog. This can cause unexpected behavior when executing
read-modify-write instructions on the affected
port.
As conclusion:
It seems Flowcode doesn't configure these automagically for Flowcode program.

Re: [WORKAROUND] 16F18877 port IO has something weird going

Posted: Wed May 31, 2017 9:32 am
by LeighM
Thanks for the info.
Updated FCD files attached.