473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

what does cmod |= 0x04 mean please it is the | i don't understand

what does the | do in CMOD |=0x04


Expand|Select|Wrap|Line Numbers
  1. /* Use timer0 overflow to clock PCA timer block
  2.       ------------------------------------_------- */
  3.    TMOD = 0x02;                   // T0 mode 2, 8 bit counter auto reload
  4.    TH0  = 0xFF;                   // Counts 1 clock(s), equivalent to 1us
  5.    TL0  = 0xFF;
  6.    TR0  = 1   ;                   // Start timer 0
  7.  
  8.    /* PCA Block clock source T0 overflow, allow interrupt
  9.       --------------------------------------------------- */
  10.    CMOD    |= 0x04;
  11.  
Apr 2 '11 #1

✓ answered by weaknessforcats

The | is the binary OR. cmod | 0x04 sets bit 0x04 since the result is true regardless of the value of the 0x04 bit in cmod.
The |= just stores the result back into cmod.
The next effect is that the 0x04 bit in cmod is set in and no other bits are affected.

3 3984
weaknessforcats
9,208 Expert Mod 8TB
The | is the binary OR. cmod | 0x04 sets bit 0x04 since the result is true regardless of the value of the 0x04 bit in cmod.
The |= just stores the result back into cmod.
The next effect is that the 0x04 bit in cmod is set in and no other bits are affected.
Apr 2 '11 #2
Banfa
9,065 Expert Mod 8TB
This reminds me of micro-processor code with CMOD and all the other variables presenting micro-processor registers. This is born out by the code comments.

If that is the case the operation is setting a bit in a micro-processor register altering the operation of some module, enabling an interrupt from the comment.
Apr 2 '11 #3
donbock
2,426 Expert 2GB
CMOD |= 0x04;
is equivalent to
CMOD = CMOD | 0x04;

That is, first a value is read from CMOD, then a new value is computed, then the new value is stored into CMOD. This may be important because you will sometimes run into a microprocessor register cannot be both read from and written to.
Apr 4 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: serge calderara | last post by:
Dear all, I would like toi understand clearly what does that tag <Serialiaze> reaaly means and when to use it and how? I have seen it in many places thanks for your answer regards serge
2
by: Valentina | last post by:
What does this C++ line mean? bool bBoolean = (0!=(nInteger&0x08)); I don't understand the nInteger&0x08 bit. Thanks, Valentina
16
by: Mars | last post by:
I am reading the code of a program from the examples, but really don't understand this one........ int i,j; ..................................................... while (scanf("%d",&i),j) {...
58
by: Larry David | last post by:
Ok, first of all, let's get the obvious stuff out of the way. I'm an idiot. So please indulge me for a moment. Consider it an act of "community service".... What does "64bit" mean to your friendly...
8
by: QQ | last post by:
SpreadsheetCell(const string& initialValue); I don't understand what & means here? Thank you very much! A C++ beginner
2
by: needin4mation | last post by:
I was looking at this code, and have seen it in other code (like it): /// <summary> /// Bitmap font class for XNA /// </summary> public class BitmapFont { private SpriteBatch m_sb; private...
4
by: riceyeh | last post by:
Hi, When reading the source code of dojo, it uses the following statement quite often. What does it mean? What I do not understand is it has a function definition enclosed in a pair of parenthesis...
16
by: macmartin | last post by:
Hi. I am new to C programming and am working through some simple bits of code. Sometimes I come across a line like: flag = (i%primes); In this case, the variable 'i', 'j' and 'flag' are...
45
by: loudking | last post by:
Hello, all I don't quite understand what does ((time_t)-1) mean when I execute "man 2 time" RETURN VALUE On success, the value of time in seconds since the Epoch is retu rned. On error,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.