Hi folks, I have attached the flowchart I have done for a darkness detector.
Everything seems to be working fine except for when I want the LED (connectd to GP5)to come on for 1 second. For som reason it it comes on for about half a second which is too quick. I've set the internal clock to 8Mhz and 4Mhz for the delays and have checked my chip configurations. For the life of me I just cannot figure out where I have gone wrong so would appreciate somebody pointing it out.
Thanks for your time.............JDR04
Timing Issue?
Moderator: Benj
-
- 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: Timing Issue?
Hi John,
The only thing I can spot is osccon value not matching clock frequency.
osccon=0x60; = 4MHz (since this is the default value on switch on then osccon is not required).
osccon=0x70; = 8MHz
Martin
The only thing I can spot is osccon value not matching clock frequency.
osccon=0x60; = 4MHz (since this is the default value on switch on then osccon is not required).
osccon=0x70; = 8MHz
Martin
Martin
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: Timing Issue?
Hi Martin, thanks for your time. Could I clear one thing up as I think I may misunderstand it.
I've got osccon=70 so I can run the chip at 8Mhz. The 4 Mhz I set was for the delay periods? Am I confusing something here????
Thanks a lot.....John
I've got osccon=70 so I can run the chip at 8Mhz. The 4 Mhz I set was for the delay periods? Am I confusing something here????
Thanks a lot.....John
-
- 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: Timing Issue?
Hi John,
The Clock speed must be set to match the actual osc speed.
All the dalays are automatically calculated.
So if osccon = 0x70; sets osc to 8MHz then you must also set clock speed to 8MHz.
Same if you have a 20MHz crystal then you must also set clock speed to 20MHz.
Etc..
Martin
Yes, I'm afraid you are.JDR04 wrote:'ve got osccon=70 so I can run the chip at 8Mhz. The 4 Mhz I set was for the delay periods? Am I confusing something here????
The Clock speed must be set to match the actual osc speed.
All the dalays are automatically calculated.
So if osccon = 0x70; sets osc to 8MHz then you must also set clock speed to 8MHz.
Same if you have a 20MHz crystal then you must also set clock speed to 20MHz.
Etc..
Martin
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact: