Page 1 of 1

16F88 configuration, please help!

Posted: Tue Nov 02, 2010 6:30 pm
by bercioiu
Hello everyone!I'm working on a project for my house.I have to build a board with 8 latching relays witch command 8 lights to my house... relays are controlled from several points in my house.I chose for this project 16F88 because i have one of these. The problem is that I need 16 I/O and to make room for all 16 I/o, I have to use the internal osc. and no MCLR.I simulated the program in Flowcode and it work well but when I upload the Hex into MCU something is wrong. I upload here the file for flowcode 4. I need help for configuration when I comiple the cip. The last configuration is in the attachment

Re: 16F88 configuration, please help!

Posted: Tue Nov 02, 2010 9:21 pm
by medelec35
Hello bercioiu
The reason your project is not working is because the default frequency for internal osc is 31.25 KHz
If you want to run internal osc at a different frequency then you will need to add a C code box at the beginning of your program with an osccon value within it.
E.g for 8MHz
osccon=0x70;
for 4MHz:
osccon=0x60;
I have modified your flowchart to run at 8MHz.
Can you please let me know if flowchart works OK for you.
Thanks.

Re: 16F88 configuration, please help!

Posted: Wed Nov 03, 2010 6:02 am
by bercioiu
Sorry modelec35 but it did not work either with the C code box added. I still have the same problem. The configuration words that I`m using are: Config1 0x3F18 and Config2 0x3FFC. Where I`m wrong?

Re: 16F88 configuration, please help!

Posted: Wed Nov 03, 2010 7:20 am
by medelec35
What is the problem you are experiencing?
I believe only problem I can see is ports staying on once activated. That is because the code is activated so fast after switch is released it would be always read as 0 and not what the flowcode simulator shows. I could be wrong. Not got time to test. If no one else answers I will test a bit later.
Is this the problem, or ports not activated at all?

Have you toggled a pin at 1Hz to see if configuration is correct?
Config settings look fine to me.

Re: 16F88 configuration, please help!

Posted: Thu Nov 04, 2010 4:33 pm
by bercioiu
I made some adjustments to the program in Flowcode (I removed the macros) and now I have the following situation: ports b0, b1, b2, b3, b6, b7 works well but at ports b4 and b5 are still the same problem: ports staying on once activated. I put here the last file from flowcode.

Re: 16F88 configuration, please help!

Posted: Thu Nov 04, 2010 10:07 pm
by medelec35
Try this. It only uses three bytes and is a very short code to toggle the whole of port B individually. Ive not done this before, so I can't guarantee it' will work 100%.
Also I have changed your osccon value to match your target speed setting. Since you have set your clock speed at 4MHz and not 8MHz. osccon should be = 0x60....not 0x70
Can you let me know if it works the way you would want it to please.

Re: 16F88 configuration, please help!

Posted: Fri Nov 05, 2010 6:43 am
by bercioiu
This version works fine.I have only one question: port B inputs are debounced ( or wait until low) ? I ask this because the buttons are a bit instable (blurry).

Re: 16F88 configuration, please help!

Posted: Fri Nov 05, 2010 7:22 am
by medelec35
Hmmm. Should be an easy fix (hopfully). How about placing a short delay just below input_portA=0 loop.
antibounce.jpg
antibounce.jpg (166.84 KiB) Viewed 10136 times
Or instead of input_portA=0 loop, you can use waituntilllow in its place.
Assuming de-bounce part of waituntilllow is ok?

So two things to try.

Re: 16F88 configuration, please help!

Posted: Fri Nov 05, 2010 5:54 pm
by bercioiu
It works very well now. I used both solutions. Thank you very much for your help! How can I give you thanks in the forum because I did not handle.

Re: 16F88 configuration, please help!

Posted: Fri Nov 05, 2010 6:09 pm
by medelec35
That's great! Glad its working for you. Thanks for letting us know.
bercioiu wrote:It works very well now. I used both solutions.
Its up to you of course, but either method should work on there own.
bercioiu wrote: How can I give you thanks in the forum because I did not handle.
To give thanks, just click on the thumbs up (next to "quote icon) In the post you wish to say thanks in.
bercioiu wrote:It works very well now. I used both solutions.
Its up to you of course, but either method should work on there own.

Re: 16F88 configuration, please help!

Posted: Fri Oct 21, 2011 5:54 pm
by bercioiu
Hello again!

Meanwhile I completed that project. Today, unfortunately, 16f88 was fried.
I have a 16F628A available. What changes should be made ​​for that MCU?
The C code box at the beginning of the program with "osccon=0x60;" for 4MHz
is the same?
Thanks again!

Re: 16F88 configuration, please help!

Posted: Thu Dec 22, 2011 9:30 pm
by medelec35
Hi bercioiu,
No I don't believe you need to add osccon=0x60; because 628A does not have an osccon register
So just try setting target speed to 4MHz, and in configuration settings set for internal osc, watchdog and Low voltage programming disabled etc.
It should then work.

Martin

Re: 16F88 configuration, please help!

Posted: Fri Dec 23, 2011 12:29 am
by bercioiu
Ok! Thanks for quick response! I'll try and return with the result.