CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Please tell me where code wrong

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 22, 2007 2:44 pm     Reply with quote

Quote:
void CHECK_Valve(float Ans)
{
if (Ans <act_valve>act_valve) & (Ans >= Inact_valve)){
output_low(PIN_D0);//Close Valve
}
}


You need to disable HTML when you post. Notice the line in bold
is garbled ? That's because HTML was enabled.


Here's how to fix it permanently, so you never have to worry about it
again.

1. Go to the main forum page, here:
http://www.ccsinfo.com/forum/viewforum.php?f=1
Make sure you are "logged in".

2. In the upper left corner of the screen, there is a "Profile" button.
Click it.

3. You will now be on your member Profile page. Scroll down near
the bottom. You will see this entry:
Code:
Always allow HTML:    Yes     No

Click on the selection for "No".

4. Then down at the bottom, click on the "Submit" button.

Now you're set. No more HTML problems. (This only works if you
always log in. If you post as a 'guest', you still need to manually
disable HTML with the tickbox below the posting window).
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Thu Mar 22, 2007 4:25 pm     Reply with quote

"break" statement in the switch statement in your interrupt is missing?
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Mar 22, 2007 6:35 pm     Reply with quote

rwyoung wrote:
"break" statement in the switch statement in your interrupt is missing?
It is better coding practice to have the break statement present but not required, he is doing a 'dirty' return from each case. It might however be that the CCS compiler is having problems with the break statements missing.

Quote:
It doesn't work when I test with my dev board. So sad
What is not working? Now we do have to guess... Guessing takes a lot of time and that's why we skip your question and go to the next person looking for help.

Code:
      Temp2=getc();
      temp[i]=Temp2;
      i++;
      if(temp[i]==0x0D){
1) Temp2 is only used locally, so don't make it a global variable. Global variables make your code much more difficult to read as we have to look all over the code if it is not used somewhere else. Also for global variables the compiler can not optimize memory usage by reusing the same memory location in another function.
2) Why did you introduce Temp2 anyway? It doesn't seem to do anything.
3) Bug: you are testing temp[i] after i was incremented, this means you are checking data in the temp-buffer which is not filled yet. My guess is this is why you introduced the Temp2 variable?

Code:
            case 'A':
                        recv1[0]=Temp[1];
                        recv1[1]=Temp[2];
                        recv1[2]=Temp[3];                     
                        recv1[3]=Temp[4];                 
               for (i=0;i<15;i++){
                  Temp[i]=0; //Clear value in Temp[]
                     }
                     MASK_value=atof(recv1);
1) Change 'i<15' to 'i<16', or even better, study the memset() function.
2)bug: atof() expects a zero terminated string, so make sure recv1[4] = 0.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group