473,395 Members | 1,457 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,395 software developers and data experts.

microcontrollers

3
Hello! have a function :
void send_addr(unsigned long addr)
{
DDRC = 0xFF;
DDRD = 0x10;
for(int i = 0; i < 16; ++i) {
if ((addr&1)) {
DATA_ADDR1
}
else {
DATA_ADDR0
}
addr >>= 1;
SRAM_CLK0
SRAM_CLK1
}
}
how to check, if the 16 bit of addr is set?
Dec 17 '07 #1
1 1236
weaknessforcats
9,208 Expert Mod 8TB
Create a mask with bit 16 set and the others reset:

1000000000000000

Usually that is done by:

1 << 15

Then AND your data with the mask:

1101001010001011
1000000000000000
-------------------------
1000000000000000

If the result is the same as the mask, then bit 16 is set:
Expand|Select|Wrap|Line Numbers
  1. if ((1 << 15) == data & (1 << 15))
  2. {
  3.     //it's set
  4. }
  5. else
  6. {
  7.     //no it's not
  8. }
  9.  
Dec 17 '07 #2

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

Similar topics

5
by: John Benson | last post by:
Regarding the message appended below: I was in a similar situation, only I had 4 "small" (RAM-wise) legacy processors in a fault-tolerant Tandem K100 system. The system came with an old Borland C++...
14
by: Evil Bastard | last post by:
Hi all, I'm currently tackling the problem of implementing a python to assembler compiler for PIC 18Fxxx microcontrollers, and thought I'd open it up publicly for suggestions before I embed too...
13
by: jay.dow | last post by:
I want to write to the pins of an RS232 without using the serial protocol. The use would be every pin could act to complete a circuit in customized hardware. I could use python to communicate...
2
by: RadGar | last post by:
Hi, I'm reposting my question in this group from comp.arch.embedded - as it was suggested to me that it might be better to do so. In advance to all reading: this is meant mostly for people who...
12
by: hkhellhkhell | last post by:
Hi Here is my current design: In the drawing function, i declared an array : PIXEL, the drawing function will keep drawing every pixel in the array to the screen. There are many kind of...
1
by: techie82 | last post by:
hi Can someone please divert me to some Tutorials on C- Programming for ARM ?? will be awesome if you can provide me some links. regards krish
30
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Let's say we had a simple function for returning the amount of days in a month: unsigned DaysInMonth(unsigned const month) { switch (month) { case 8: case 3: case 5:
33
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I'll try to summarise this as best I can, as my last thread wasn't very to-the-point: The C Standard says the following two things: * int is the natural integer type for the system. * int...
11
by: test | last post by:
Hi, I'm very new to Javascript so maybe my question could be stupid. I'm playing with microcontrollers and a TCP/IP component. This means that I can control electronics via TCP/IP, UDP and so on....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.