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.
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.
Oh, Thank you!
Another question : How can I know the battery address in the SM Bus ?
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.
Depends on which SMbus device is used by the battery monitor.
Originally Posted by yanol
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.