| Author |
Message |
|
|
Posted: Feb 05, 2010 - 04:44 PM |
|


Joined: Jul 18, 2005
Posts: 33138
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
To be honest I have extreme difficulty following your ISR and what's likely to happen. This isn't helped by use of variable names such as inter, inter1, inter2.
OK so they are variables used in the interrupt but it'd be more heplful if the variable names gave some indication of what they were being used for. Is it something like button_state or similar?
Also what on earth does:
Code:
if(counter2 PCT2==0)
intend to do? Does the compiler not complain about this syntax? What is "PCT2" anyway? A #define ?
Also the states in your ISR have:
Code:
{ while(1)
Not only do I not like statements after '{' (put the while on a new line) but having indefinite code in an ISR is terrible as Mike said above.
Can I suggest you take a step back and just describe in words what you think the steps in the ISR are trying to achieve - the key to programming is doing 90% of the work during the design stage - the implementation is then just 10% of the job (OK there's another 90% for debugging but that's a different can of worms!)
Either putting in words or drawing a flowchart the steps of what you are trying to achieve, breaking the big steps into smaller, more detailed steps until you have something that converts almost one to one to lines of C is the way to do this.
I fear that if this really is a project that has to be complete today that you are not going to make the deadline. Even if you are on the west coast of the US (Hawaii even) there aren't enough hours left to complete this today  |
_________________
|
| |
|
|
|
|
|
Posted: Feb 08, 2010 - 04:40 PM |
|


Joined: Dec 30, 2005
Posts: 2041
Location: Longmont, CO USA
|
|
|
aymank1985 wrote:
But when you say you read the current state you mean from PINX right?
Yup.
Stu |
_________________ Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.
(My boss always chooses Cheap. Twice.)
|
| |
|
|
|
|
|
Posted: Feb 09, 2010 - 06:32 AM |
|

Joined: May 02, 2007
Posts: 992
Location: Nieuwegein, Netherlands
|
|
Cliff,
the answer to this question:
Quote:
intend to do? Does the compiler not complain about this syntax? What is "PCT2" anyway? A #define ?
is basically this line in my post:
Quote:
The problem was the Percentage sign. for some strange reason this is not allowed in a code block.
it should be "counter <<percentage sign>>2 == 0" but that was not allowed inside the code block. My mistake, I should have perhaps been a bit more clear about the replacement.
Stu, if aymank1985 has read your thread and is understanding it he should be making a fress start as of now. Nice explenation.
I still do not graps the full situation, something is not right. until now we never have seen any teachers throwing their students in the deep, there has always been some sort of basic framework that they had and that atleast should have get them going. I miss that here at all. Also I think that aymanks basic knowledge is not even near where it should be to complete this task. I can not imagine that the start has not been to make a polling loop and then convert that to a interrupt based situation. This is the wrong way around. and also if this is the code he has showed the teacher for a full interrupt based system the teacher should hav tolled him that he is not doing the things in a smart way...... |
_________________ Best friends:
1) Datasheet (and application notes)
2) AVR freaks forum( specially the tutorials
3) Fellow freaks, Can answer to problems that could not be answered by 1 or 2
|
| |
|
|
|
|
|
Posted: Feb 09, 2010 - 09:24 AM |
|


Joined: May 04, 2007
Posts: 766
Location: Geelong Australia, Home of the "Cats"
|
|
I hope someone can help me with a small hint .
I would have though that there lots of "really big hints by most respondents". I can't see a little hint making any difference.
It would also be nice to see the actual "task" that you were given, as there may be a difeerence what your are asked to do and, what you perception of what you were asked to do! |
_________________ Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
(If you haven't already done so, edit your PostNuke profile and let let us know where you are, what you do & what your interests are.)
|
| |
|
|
|
|
|
Posted: Feb 09, 2010 - 03:21 PM |
|


Joined: Dec 30, 2005
Posts: 2041
Location: Longmont, CO USA
|
|
|
LDEVRIES wrote:
It would also be nice to see the actual "task" that you were given, as there may be a difeerence what your are asked to do and, what you perception of what you were asked to do!
"I know you think you understand what you thought I said, but what I doubt is what you heard is not what I meant."
Or something like that.
Stu |
_________________ Engineering seems to boil down to: Cheap. Fast. Good. Choose two. Sometimes choose only one.
(My boss always chooses Cheap. Twice.)
|
| |
|
|
|
|
|