Thread: Registers, C++

  1. #1
    Registered User
    Join Date
    Jun 2008
    Location
    Israel
    Posts
    7

    Registers, C++

    Hello ,

    I’m fairly new to programming in this subject. I would like some help!!!

    I’ve CPU with chip Winbond (W83627HG - AW). The chip reads data from SM Bus that connects to an external battery. I need to read a voltage of the battery from a chip.

    Please explain me what I need to do, and how can I do this, step by step.
    Thanks!!!

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    You need to do two things:
    1) Get a C++ compiler for that particular chip's architecture. If you can't find one, then you can't use C++.
    2) read the documentation of the chip to understand how to access the SM bus.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  3. #3
    Registered User
    Join Date
    Jun 2008
    Location
    Israel
    Posts
    7
    Oh, Thank you!
    Another question : How can I know the battery address in the SM Bus ?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The Winbond chip is the Southbridge (I/O component) of a motherboard, not a CPU in itself.

    If you are using Windows or Linux, you would need to talk through a SMbus driver - this driver is most likely already in existence, and if it's not, you can't use C++ to write one.

    You will then need to know what battery monitor chip is connected to the SMBus, and use the SMbus driver interface to interrogate the chip.

    And no, I don't know how this is done. In linux, there's a package called lm-sensors that will give you access to all sort so SMbus devices.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by yanol View Post
    Oh, Thank you!
    Another question : How can I know the battery address in the SM Bus ?
    Depends on which SMbus device is used by the battery monitor.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    I don't know how to do this, but I think it won't be easy...

    When you are not constrained by the operating system, you can easily use a pointer to read a hardware register (if you know the address).

    I don't know if the address is even published. With modern operating systems, this detailed kind of information is sometimes only known by the hardware manufacturer. The hardware manufacturer writes the driver, and they might publish information on how to communicate with the driver.

    But, windows (after Win98) will not allow a user-mode program to directly access a hardware address. (I think the same is true with Linux.)

    One option is to write a kernel-mode driver. Of course, you would need to know the address. And although this would be a simple driver, it's not trivial to write a driver if you've never done it before. (I've never actually written a driver myself, but I have a book on the subject.)

    Another option is to use an existing driver. Your application will communicate with the driver, which will in-turn communicate with the hardware. This is how "normal" windows programming is done. The application never directly comunicates with the hardware. In this case, you don't need the register address... The driver knows the address. All your program has to do is execute the proper function.

    I assume your system has an existing driver. But, I don't know how to communicate with the driver. It might be easy (if you can find the documentation), or it might be impossible...

    ...For common devices (like printers) there are standardized functions for communicating with the driver. i.e Microsoft Visual C++ includes these functions... They are standardized (by Microsoft) for Windows. They are not part of the ANSI C++ standard. It is the responsibility of the hardware manufacturer (or driver writer) to write a driver that responds correctly to these functions.

    ...For some specialized hardware/drivers, the hardware manufacturer does not publish these driver interface functions, and only the hardware manufacturer's own application will work with the hardware/driver.
    Last edited by DougDbug; 06-04-2008 at 05:13 PM.

  7. #7
    Registered User
    Join Date
    Jun 2008
    Location
    Israel
    Posts
    7
    Thank you,DougDbug

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Accessing HW registers using bit fields and UINT32
    By samdomville in forum C Programming
    Replies: 4
    Last Post: 12-10-2008, 01:00 PM
  2. Replies: 10
    Last Post: 12-05-2008, 12:47 PM
  3. Using MMX & XMM Registers
    By HyperShadow in forum C++ Programming
    Replies: 3
    Last Post: 07-14-2007, 12:53 AM
  4. memcpy with 128 bit registers
    By grady in forum Linux Programming
    Replies: 2
    Last Post: 01-19-2004, 06:25 AM
  5. Registers
    By Golden in forum C Programming
    Replies: 2
    Last Post: 09-04-2001, 11:48 AM