I can count myself as a real rookie now!!
Now that my program is growing, I encountered a new problem.
The program is now some sort of stopwatch with 1 control button on portb.4.
The problem is, that when I press the button, the timer won't start and it goes straight to "The time is: 00,00"
What do I miss here?
anyone? ^^
Cheers,
William
/EDIT While I studied the behaviour of the program, I saw something odd... When i press RB4, INTCON.0 is set, BUT the interrupt enable bit is cleared on the same time. That's why it doesn't interrupt.
Now I have forced the enable bit to stay set, only when I run it then it gives me an adress missmatch error. So that isn't the solution...
Anyone with a clue what might reset INTCON.3?
Last edited by WishMaster^; - 19th April 2007 at 13:02. Reason: Added a founding......
------------
Oh Noes...
------------
Okay, in debug mode all works fine now, but, when I compile and load the program without the debugger, then it goes bananas. What I suspect now, is that there is a signal in PortB what is resonating when I press the button. This will cause many interrupts, making the microcontroller think that I press the stop button right away.
That will explain why it skips the interrupt routine without the debugger on...
Before I order any parts to solve this, I want to know if I'm close or not. So is this a problem that might occure while making something like this?
Cheers,
William
------------
Oh Noes...
------------
I don't think I'd be listening to that guy too much.Originally Posted by WishMaster^
If you are using a chip with more than 2K of program memory,PBP automatically inserts code to do the context saving. It uses the wsave, ssave and psave variables. Why? I don't know. But it does.
In the process of saving the context, it also changes the W and STATUS registers. So if you try to save and restore it with different variables, you're only saving the changed values. Then the real values never get restored.
This will send PBP to the Funny Farm. Or at least the person trying to figure it out.
So, lose the saving portion of the interrupt handler, then change the restore section to what's shown in the manual.
HTH,
DT
Allright! I already had my doubts about that! I changed it back right away and it works just as great! Thanks!
I fixed the problem with the "resonating signal". Turned out I used a wrong capacitor so the signal sticked in the forbidden area too long...
Back to newbie class for me I guess, haha.
Now comes the real challenge, 3 time measurements at the same time with 3 different start/stop buttons. All working on interrupts... Wish me luck!
Cheers,
William
------------
Oh Noes...
------------
For those who want to make a Stopwatch, here is my code for it. You will have to tune Timer0 for exact readouts since it is not perfect yet. By 30 seconds it will be 1,5 seconds off (28,5 sec)
It counts from 100 uS
Have fun building your stopwatch
Thanks to all who helped me to make the code as it is now!
Cheers,
William
P.S, I'll keep you all informed about the 3-stopwatch-at-the-same-time-based-on-interrupts-program![]()
------------
Oh Noes...
------------
I almost hate to point this out to you since you've already got all this work into your project/code...but...
Do a search on 'Olympic Timer'...
You'll find a timer that Melanie did awhile back, and it's very accurate...well, at least as accuracte as your oscillator is.
Bookmarks