Stuck in a while loop

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

panuj417
Posts: 2
Joined: Sat Oct 26, 2019 9:33 am
Contact:

Stuck in a while loop

Postby panuj417 » Sat Oct 26, 2019 9:57 am

I am using a PIC16F886.
I am a beginner in this field.
I stuck in a while loop.
anybody help me?
https://drive.google.com/open?id=1KqXQXS5e7B4o_ODSvgxe9VvJSkEQiMB6

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

Re: Stuck in a while loop

Postby medelec35 » Sat Oct 26, 2019 10:51 am

Hi panuj417 ,
I have moved your post, so not hijacking a members topic.
One issue is you are reading the value of a button, if the value is true, then the loop is accessed.
There is not a button to read within the loop, so the value will never go from 1 to 0.
You can just place another Button ReadState within the loop.

You also have some issues with your configuration.
For example Watchdog and Low voltage programming is enabled, which will cause issues.

With loads of chips including PIC16F886, It is the value of

Code: Select all

OSSCON
register that set up the hardware internal osc speed.
The Clock speed within Flowcode sets up timing for all timed critical components and delays.
Looking at the data sheet (page 62) for PIC16F886 the default value is 4MHz.
This means no matter what you set the clock value to, the chip will always be running at 4MHz!
To get the hardware to run at the correct speed, the easiest way within Flowcode is to use the intosc component.
Just click on the search(magnifying glass) and enter intosc
This is how you use the intosc component.
Please follow it all, as you will need to add a C code bock with the correct value.
Whenever I start a project with a new target device, I always run a flash test to make sure the chip is running at the correct speed.
These users thanked the author medelec35 for the post (total 2):
AbhijitR (Sat Oct 26, 2019 1:21 pm) • astro1234 (Sat Oct 26, 2019 2:33 pm)
Rating: 10.53%
 
Martin

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

User avatar
AbhijitR
Posts: 79
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 106 times
Been thanked: 18 times
Contact:

Re: Stuck in a while loop

Postby AbhijitR » Sat Oct 26, 2019 1:23 pm

Hello! Martin

As usual every time I read your post I learn something new, thanks for the IntOsc Helper, many thanks to Matrix Team too.

Regards
Abhi
These users thanked the author AbhijitR for the post:
medelec35 (Sat Oct 26, 2019 2:27 pm)
Rating: 5.26%
 

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

Re: Stuck in a while loop

Postby medelec35 » Sat Oct 26, 2019 2:29 pm

Hi Abhi,
Thank you for the nice comments.
You are very welcome.
Glad we have helped you to learn new things :)
Martin

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