16F88 configuration, please help!
Moderator: Benj
-
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
16F88 configuration, please help!
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
- Attachments
-
- config.jpg (208.35 KiB) Viewed 8767 times
-
- teleruptor.fcf
- (24.72 KiB) Downloaded 277 times
-
- 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: 16F88 configuration, please help!
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.
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.
- Attachments
-
- teleruptor Modified.fcf
- (25.22 KiB) Downloaded 318 times
Martin
-
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: 16F88 configuration, please help!
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?
-
- 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: 16F88 configuration, please help!
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.
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.
Martin
-
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: 16F88 configuration, please help!
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.
- Attachments
-
- teleruptor_1.fcf
- (22.33 KiB) Downloaded 284 times
-
- 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: 16F88 configuration, please help!
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.
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.
- Attachments
-
- teleruptor_modifiedV2.fcf
- (8.5 KiB) Downloaded 315 times
Martin
-
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: 16F88 configuration, please help!
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).
-
- 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: 16F88 configuration, please help!
Hmmm. Should be an easy fix (hopfully). How about placing a short delay just below input_portA=0 loop.
Assuming de-bounce part of waituntilllow is ok?
So two things to try.
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.
Martin
-
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: 16F88 configuration, please help!
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.
-
- 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: 16F88 configuration, please help!
That's great! Glad its working for you. Thanks for letting us know.
Its up to you of course, but either method should work on there own.bercioiu wrote:It works very well now. I used both solutions.
To give thanks, just click on the thumbs up (next to "quote icon) In the post you wish to say thanks in.bercioiu wrote: How can I give you thanks in the forum because I did not handle.
Its up to you of course, but either method should work on there own.bercioiu wrote:It works very well now. I used both solutions.
Martin
-
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: 16F88 configuration, please help!
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!
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!
-
- 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: 16F88 configuration, please help!
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
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
Martin
-
- Posts: 161
- Joined: Sun Feb 25, 2007 10:56 am
- Location: bucharest, romania
- Has thanked: 90 times
- Been thanked: 34 times
- Contact:
Re: 16F88 configuration, please help!
Ok! Thanks for quick response! I'll try and return with the result.