Attachments are accessible only for community members.
Anonymous
Not applicable
Apr 02, 2014
06:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
06:47 AM
Hello I cant make this simple code work: if ((PRT0DR & pin5) && (startknap_lys==0)){startknap_lys=1;PRT0DR |= pin3;while(PRT0DR & pin5){}} It only has to check in input port and a value in an int. If I remove the integer it works fine. I have made it work before with checking two variables in an if statement. Both with & or &&. This has worked before: if ((value<=15)&&(value>=5)&&(skygge==1)){} And this aswell: if( (LDR_1 < 51) & (LDR_2 < 51) & (LDR_3 < 51) & (LDR_4 < 51) ) //Checking the light intensity on all 4 LDR´s So I cant seem to figure out why it doesn't want to work now. Though this is the first time I check both and input port and a variable and not only variables. Thanks And for the record, my code works, just not when I add the variable. This is the whole code:
Labels
- Labels:
-
PSoC 1
10 Replies
Anonymous
Not applicable
Apr 02, 2014
06:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
06:53 AM
Well the picture isn't the whole code, but the only thing you need of it 🙂
Apr 02, 2014
06:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
06:59 AM
It would be better to post the complete project, so we all can have a look at. Use Designer's function "Archive Project" and upload the resulting .zip here (DO NOT use chrome, it won't work!)
Bob
Anonymous
Not applicable
Apr 02, 2014
07:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
07:03 AM
& is a bitwise AND, && is a logical AND.
Have you looked at using shadow registers ?
http://www.cypress.com/?rid=2900 AN2094
Regards, Dana.
Anonymous
Not applicable
Apr 02, 2014
07:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
07:04 AM
I made it work by using 2 if statements after each other. I am not satisfied with that solution 😄 Apparently you cant check a port and a variable in the same if statement, atleast for my conclusion. And I find that odd and weird and painfull and... but I still like PSOC
Attachments are accessible only for community members.
Anonymous
Not applicable
Apr 02, 2014
07:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
07:09 AM
Anonymous
Not applicable
Apr 02, 2014
07:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
07:11 AM
Hello Dana No I havnt, and I cant do that right this week 🙂 too busy. But I made it work with both & & && xD if you get me. I have to read up on the difference between those two.
Anonymous
Not applicable
Apr 02, 2014
07:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
07:14 AM
Im off again for the next 8 hours.
Attachments are accessible only for community members.
Anonymous
Not applicable
Apr 02, 2014
07:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
07:41 AM
Anonymous
Not applicable
Apr 02, 2014
07:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
07:52 AM
One last comment. I have seen compilers choke, sometimes with no warning or
error, on highly compounded staements. In my case embedded compund f()
calls. I am prone to writing code like that, but now primarily use simple statments
on a line by line basis. Compilers are imperfect tools.
Just a thought.
Regards, Dana.
Anonymous
Not applicable
Apr 02, 2014
03:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2014
03:47 PM
It aint that I don't want to read up on it, it is just that I doesn't have the programming as a job. Also I forget stuff. I learned it once in my education, but my job didn't went that way, so I forget the bitwise thing. I read up on it now, but never can remember everything. What you say about the compiler thing might be right. I cant see how it shouldn't work with my code, and also has reference to other codes written in same way that works. So it might be a compiler problem. Anyway thanks