Embedded C/C++

Moderators: Lundin
Number of threads: 199
Number of posts: 374

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Re: Can you help me with Defining header file and setting bits ?? Posted by Lundin on 14 Apr 2009 at 11:17 PM
: define a bit
: unsigned char data Bits 0x20;

That's what I did in the first example. Try to dissect that one:

Since you can only work on byte level on most computers, you need to mask out the bit you are interested in, in this case bit 5, since 0x20 equals bit number 5. You mask out this bit without destroying the other bits. That's when the bitwise OR (|) and AND (&) operators comes in.

Needless to say, you must understand binary and hexadecimal numbers before starting to learn any form of programming.



: sbit GoingHigh Bits^0;

This means nothing, it is gibberish.


: then you need a counter byte, define it in your .h
: unsigned char data Counter 0x30;

What do you mean "counter byte" and what has 0x30 to do with that? I don't understand what you are trying to do.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.