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

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

EtsDriver
Valued Contributor
Valued Contributor
Posts: 431
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 346 times
Been thanked: 224 times
Contact:

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

Postby EtsDriver » Sun May 28, 2017 9:48 pm

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:
Attachments
16F18887 tester.fcfx
(15.3 KiB) Downloaded 84 times
Ill just keep the good work up!

bernoulli
Posts: 21
Joined: Sat Dec 12, 2015 10:18 am
Has thanked: 1 time
Contact:

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

Postby bernoulli » Mon May 29, 2017 6:19 am

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8612
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2477 times
Been thanked: 3561 times
Contact:

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

Postby medelec35 » Mon May 29, 2017 10:44 am

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
These users thanked the author medelec35 for the post:
EtsDriver (Mon May 29, 2017 2:54 pm)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

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

Postby Kenrix2 » Mon May 29, 2017 11:25 am

PORTx reads when it's ANSELx bits are set will always return a zero.
These users thanked the author Kenrix2 for the post:
EtsDriver (Mon May 29, 2017 2:59 pm)
Rating: 5%
 

EtsDriver
Valued Contributor
Valued Contributor
Posts: 431
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 346 times
Been thanked: 224 times
Contact:

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

Postby EtsDriver » Mon May 29, 2017 2:53 pm

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
now it works thanks.PNG (2.62 KiB) Viewed 2853 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.
Attachments
16F18887 tester.fcfx
(16.16 KiB) Downloaded 85 times
Ill just keep the good work up!

User avatar
LeighM
Matrix Staff
Posts: 2008
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 480 times
Been thanked: 688 times
Contact:

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

Postby LeighM » Wed May 31, 2017 9:32 am

Thanks for the info.
Updated FCD files attached.
Attachments
16F188xx.zip
(34.86 KiB) Downloaded 97 times
These users thanked the author LeighM for the post:
EtsDriver (Wed May 31, 2017 2:55 pm)
Rating: 5%