473,387 Members | 3,684 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,387 software developers and data experts.

how to declare and read/write to a memory register in C

Hello
I am new to group, and new to development.
I have question. I am doing project on embedded, need to read/write to the registers of the microprocessor.

Two questions:
1. How to declare?
Maybe use pointer.
#define TX_Register 0x30008000
long * tx_reg = TX_Register
Is this correct?
Is it possible to use maybe double pointer?
long ** tx_reg = ???
Please help with syntax in declaration.

2. How to access/ read/write/reference the register using the pointer (or double pointer)?

Thank you.
Jun 22 '07 #1
1 4557
weaknessforcats
9,208 Expert Mod 8TB
I'm not sure you can write to specific registers using C or C++.

You can declare a register variable:
Expand|Select|Wrap|Line Numbers
  1. register int value;
  2.  
as a suggestion to the compiler that value should be in a register rather than a variable in memory but I don't think you can specify the precise register.

If you are using Visual Studio, you can drop into assembly by invoking the inline assembler:
Expand|Select|Wrap|Line Numbers
  1. __asm
  2. {
  3.      //assembly code here
  4. }
  5.  
Otherwise, I am at a loss.
Jun 22 '07 #2

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

Similar topics

13
by: Don Kim | last post by:
I'm writing a program to read 2,000,000 floating point numbers off a text file, to compute the sum, mean, and median. This is a direct example of Stroustrup's paper. But the program will not...
19
by: Geetesh | last post by:
Recently i saw a code in which there was a structer defination similar as bellow: struct foo { int dummy1; int dummy2; int last }; In application the above array is always allocated at...
19
by: Hal Styli | last post by:
Hello, Can someone please help. I need to use a large array and I'm not sure when one should use (A) and when one should use (B) below:- #define MAX 10000000 (A) int x;
11
by: Eric A. Johnson | last post by:
Hi, The book I am studying from, which comes from 1994, makes mention of far memory (i.e., that memory beyond 64K). I am under the belief, however, that far memory no longer needs any special...
2
by: lamalice | last post by:
Hi, i want read the byte at this adress : 0x03fd. It's the adress of the Line Status Register of the port COM1. There is a bit who signal the end of sending. I need read this bit but i don't...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
1
by: Ron | last post by:
Hello, I need to create/instantiate a global class library project so that 2 EXE's can write to the same class library form in the same instance of the class libary. I am thinking something...
1
by: peary | last post by:
Hi, everyone, I'm writing a program to discover wireless network using Windows Native Wifi API & VB.net. I have to declare the windows API in my VB.net program. The original windows...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...

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.