LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 11-10-2010, 04:22 AM   #1
raulapati
Member
 
Registered: May 2010
Posts: 51

Rep: Reputation: 0
Question how to set a bit in register in linux flat form..


hai to all...

can any body tell me how to acess a bit of 8 bit register in linux flatform..

as in controller point of view we have sbit to set abit of register..but how can i set bit in case of linux..

for example:
unsigned char INTERRUPT;
now i have to set diffetrnt flags to each bit of INTERRUPT..



please help mee.
thanks in advance.....
 
Old 11-10-2010, 02:32 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,854

Rep: Reputation: 161Reputation: 161
set_bit : set a bit at the position.
clear_bit: clear a bit at the position.
 
Old 11-11-2010, 03:25 PM   #3
lqu
LQ Newbie
 
Registered: Aug 2009
Posts: 15

Rep: Reputation: 0
I guess you are talking about the control/status/data registers in devices, rather than the CPU registers, which you need assembly language to access.

to set the n-th bit of x:
x |= 1<<n;
to clear the n-th bit of x:
x &= ~(1<<n);
to toggle the n-th bit of x:
x ^= 1<<n;

If you want to write all bits, just write a number to the register. For example, to accknowledge interrupts, write 0xFF to interrupt register.
 
Old 11-22-2010, 07:21 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Where is the register which you want to modify? If it is a CPU register, it may not be possible, or meaningful, except from kernel space. If it is a register in a memory-mapped or IO-mapped (x86) peripheral, then you can use the /dev/mem or /dev/port facilities. It may also be on something like a PCI or similar bus, in which case there are probably kernel facilities available to access the register.
The boolean logic to access a particular bit has been demonstrated by earlier posters.

--- rod.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Assistance needed to set up RHEL 64-bit as a YUM Proxy server for 32-bit also. xenner Linux - Newbie 7 10-19-2009 08:50 PM
anyone form BIT,China? urright LinuxQuestions.org Member Intro 1 11-09-2007 04:05 PM
Memory bus is 64 bit but data access and register is only 32 bit for i386 lilzz Linux - Newbie 3 09-02-2006 12:35 AM
I want Linux source code for FAT file system in user readable form not in binary form ramya272 Linux - Newbie 5 02-05-2004 07:54 PM
Mandrake 8.2 - can not register boxed set Haldir Linux - Newbie 2 05-07-2002 08:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 05:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration