[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

Post Reply
EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times
Contact:

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

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

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

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

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

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

Post 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
Martin

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...

Post by Kenrix2 »

PORTx reads when it's ANSELx bits are set will always return a zero.

EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times
Contact:

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

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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

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

Post by LeighM »

Thanks for the info.
Updated FCD files attached.
Attachments
16F188xx.zip
(34.86 KiB) Downloaded 248 times

Post Reply