473,473 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

part of a c-code

Hi,

I have a function that checks or compare to see if the read value is same as
the written value in the register. (i.e. check if READ_value==WRITE_value in
REG_1)
It also checks if the READ==WRITE, then writes a value of 0x1 in REG_2.

Thank you for your suggestion, if the code below would do the same.
Kind regards,
vick

//--------------------------------------------------------------------------
---
// Function to check if the written value in the variable is same as the
read value
//--------------------------------------------------------------------------
---
int Prog(const Info *progInfo) {

int errors=0;
if (progInfo!=NULL) {
Regs RegPoint;
unsigned int i;
UInt32 tmp0;
int sig = 1;

/* Set registers base address */
RegPoint = (Regs)progInfo->location;

/* Write a value in the register */
// See if the value written in REG_1 writes a value in REG_2
PrintfMessage("Starting REG_2 test at %x\n", RegPoint);
RegPoint->REG_1 = 0x0F;
/* Read data of REG_1*/
/* See if REG_2 is triggered.... \n") */
tmp0 = RegPoint->REG_1;
if (tmp0 == 0x0F) {
sig = 0;
PrintfMessage("REG_2 is not triggered %x\n", RegPoint);
} else {
vhPrintfMessage("REG_2 is triggered %x\n", RegPoint);
}
PrintfMessage("Now clear the value in REG_2 %x\n", RegPoint);
RegPoint->REG_2 = 0x00;
return (sig);
}
return errors;
}
Apr 14 '06 #1
1 1438
On Fri, 14 Apr 2006 22:41:43 +0200, "vicky" <vi***@yahoo.com> wrote:
Hi,

I have a function that checks or compare to see if the read value is same as
the written value in the register. (i.e. check if READ_value==WRITE_value in
REG_1)
It also checks if the READ==WRITE, then writes a value of 0x1 in REG_2.

Thank you for your suggestion, if the code below would do the same.
I do not see where 0x1 is written into REG_2. Please note that it is
hard to read code with unknown definitions.
//--------------------------------------------------------------------------
---
// Function to check if the written value in the variable is same as the
read value
//--------------------------------------------------------------------------
---
int Prog(const Info *progInfo) {

int errors=0;
if (progInfo!=NULL) {
I hate to read through a long body statement hoping that I do not miss
the ending brace. Why not just exit if progInfo is null?
Regs RegPoint;
unsigned int i;
UInt32 tmp0;
int sig = 1;

/* Set registers base address */
RegPoint = (Regs)progInfo->location;

/* Write a value in the register */
// See if the value written in REG_1 writes a value in REG_2
PrintfMessage("Starting REG_2 test at %x\n", RegPoint);
RegPoint->REG_1 = 0x0F;
/* Read data of REG_1*/
/* See if REG_2 is triggered.... \n") */
tmp0 = RegPoint->REG_1;
Did you mean 'tmp0 = RegPoint->REG_2;'? As written tmp0 must be 0x0f. if (tmp0 == 0x0F) {
How can this conditional not be true?
sig = 0;
PrintfMessage("REG_2 is not triggered %x\n", RegPoint);
} else {
vhPrintfMessage("REG_2 is triggered %x\n", RegPoint);
}
PrintfMessage("Now clear the value in REG_2 %x\n", RegPoint);
RegPoint->REG_2 = 0x00;


I thought that you wanted the value to be 0x1?

HTH.
--

Best wishes,

Bob
Apr 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Jim Cochrane | last post by:
I just google-searched this group and could not find any references to this. I'm trying to figure out how to specify a three-part header with html. For example, left part ...
2
by: Alf P. Steinbach | last post by:
The sixth part of my attempted Correct C++ tutorial is now available, although for now only in Word format (use free Open Office if no Word), and also, it's not yet been reviewed at all -- ...
2
by: JumpinJeff | last post by:
I am about to revamp the most referenced table in my whole database and am unsure the best way to approch it. The table's primary key is also used as a part number for all the items in the table. ...
3
by: ChadDiesel | last post by:
Hello everyone. I need some advice on table structure for a new project I've been given. One of our customers sends us an Excel spreadsheet each week containing their order. Currently, someone...
7
by: Shannan Casteel via AccessMonster.com | last post by:
I have a form for entering part numbers along with the associated quantity for each part. There are 25 Part fields and 25 associated Quantity fields. If I go to record 1 and enter part number 1234...
2
by: maxw_cc | last post by:
Hi to all of you, I was wondering what the Semantics part in C standard is really for? What should be on the constraints part and what should be on the semantics part? Is the implementation...
5
by: ad | last post by:
I have a string like string myString="dog,cat,dog,tiger" I want to delete the duplication part, and make myString to "dog,cat,tiger" How can I do that?
2
by: | last post by:
There is a guy on eBay who is selling several copies of Visual Studio.NET Enterprise Architect 2003. He had the part number listed as X09-60942, but I couldn't find it listed in Microsoft's product...
3
by: blackswift | last post by:
Hello all, I know STL is part of the standard. Is STL a part of C++ language? I heard scanf function is not a part of C. Best regards.
35
by: Lew Pitcher | last post by:
On November 14, 2008 15:00, in comp.lang.c, Nomen Nescio (nobody@dizum.com) wrote: Overkill Try
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.