Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Registers, C++

  1. #1
    Join Date
    Jun 2008
    Posts
    11

    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
    Join Date
    Dec 2003
    Location
    3dbuzzmania
    Posts
    4,064
    I think you will need to use Assembly for this sort of thing first, unless your Winbond chip shipped with some instructions or compiler that works with C++.

    Usually Chips come with instruction sets. You will need those.

    Page 15 of this pdf shows you the pins of the chip followed by description.
    Page 46 shows you the registers.
    Page 84 shows you some of the Assembly instructions.

    http://beta.octopart.com/Winbond__W83627HG-AW.pdf

    Have fun.
    Last edited by TF242; 06-04-2008 at 10:42 AM.

  3. #3
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    this is probably not a c++ question at all (unless you already have a library for interfacing with the chip, which does not seem to be the case).

    here's what you'll need to do: first of all, you'll need a full manual of the W83627HG chip. the datasheet won't be sufficient, as you'll probably need the full instruction set. winbond's homepage is a damn mess (tried to find a manual there myself once ), so this might already be a bigger problem than expected.
    next, you'll need to find out how the chip is interfaced from your cpu. if the chip is soldered on the mainboard, you'll have to check your mainboards manual for this, if it's on an external device (e.g. connected via parallel port), check out the controller chip and get a manual for it.
    finally, you'll need to consider your cpu's manual to find out how to interface hardware with it. this will probably require some knowledge with your cpu's assembly language. things will get a lot easier if you find a library for c++ that does this kind of low-level-interfacing for you, since it does not only prevent you from having to use assembler, but also keeps you away from potential trouble with the operating system, restricting direct hardware access.

    unfortunately, all of this might be way over your head if you're completely new to programming. i'm not telling you to give up, i'm just saying it might take some time and effort to accomplish.
    if you tell us some more about your environment (where is the chip located? how is it connected to your machine? what machine are you actually using?), we will try to help you some more...


    edit: seems tf242 was a little faster

  4. #4
    Join Date
    Dec 2003
    Location
    3dbuzzmania
    Posts
    4,064
    Only because you typed a longer reply.

    Btw: I noticed you're from Trier Germany. I was in Trier many times, especially when visiting Luxembourg and when visiting Spangdahlem Air Base.

    Not too far from were I lived in Bad Kreuznach by Mainz. Small world.
    Last edited by TF242; 06-04-2008 at 11:11 AM.

  5. #5
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by TF242 View Post
    I was in Trier many times, especially when visiting Luxembourg and when visiting Spangdahlem Air Base.

    Not too far from were I lived in Bad Kreuznach by Mainz. Small world.

    cool thing. a small world it is, indeed

  6. #6
    Join Date
    Jun 2008
    Posts
    11
    Thanks for your help

  7. #7
    Join Date
    Jun 2008
    Posts
    11

    Lightbulb

    [QUOTE=ComicSansMS;1375530]
    I'm working with SBC84620 machine. I know wich register of chip I must to use. But I don't know how can I read battery data via SM Bus

  8. #8
    Join Date
    Oct 2006
    Location
    Melbourne
    Posts
    743
    Although the organization and layout of the PDF above leaves a little to be desired, I think there's actually enough info to work with.

    Contrary to statements above, there's no instruction set you need to know for these chips. All you need to know when interfacing with them is which ports to use to send data out, and which ports to read data in from.

    In the case of this chip, it's 0x295 is the port used for OUT instructions and 0x296 used for IN instructions.

    Going from the stuff on printed p75 (acrobat p79), it seems as though you can just read the value from index 0x51. Or to put it another way, execute the following code:

    Code:
    ; step 1 - let chip know we want data from index 0x51
    mov dx, 0x295
    mov al, 0x51
    out dx, al
    
    ; step 2 - read the battery voltage
    mov dx, 0x296
    in  al, dx    ; I think they're 8 bit values - if 16, use in  ax, dx
    I've no idea what the range will be, or what the multiplier is - obviously bat voltage is a floating point number, yet you're only dealing with 8/16 bits. It might require some investigating of the values for VBAT upper and lower limits (indexes 0x56 & 0x57) - I'd check the upper and lower limits, and see how/if they correspond to 2.2 & 4.4 volts in some way.

    Failing that, I'd just ensure that VBAT monitoring was enabled, before going into a loop of checking if the voltage is in bounds, then reducing the upper bound limit & re-checking. Once the voltage was found to be out of bounds, you would know that the VBAT is somewhere between the VBAT upper limit and the last value of this limit. Note that you need to allow at least 300ms for each loop, otherwise the monitoring process may not have had time to set the bit that tells you if VBAT was over-limit.

    I'd have a go at some code, but I've haven't got one of the chips.

    If you're using VS, just grab a copy of Masm32 and create an object file using assembly. If you're using GCC, I think you'll need Nasm.
    Create the appropriate header & (if I remember correctly DEFfile) then just link this object file into your project. I forget how exactly, it's been years since I did it last. You'll find plenty of tutes on how to interface to asm code using C/C++

    I don't know how you'll go getting access to the I/O ports under windows, I've a feeling that you can't access the hardware directly, and that you need to get windows to do it for you. Dunno how, never done it - the last I/O port stuff I did was the VGA pallete regs & the OPL chip on a SoundBlaster16 card - both under dos.

    Hope this's been useful.
    S.
    Last edited by enhzflep; 06-05-2008 at 11:16 AM. Reason: mis-typed first index number (0x51 - was 0x50) in code

  9. #9
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by enhzflep View Post
    Contrary to statements above, there's no instruction set you need to know for these chips. All you need to know when interfacing with them is which ports to use to send data out, and which ports to read data in from.
    by "instruction set", i was referring to the cpu's isa, which you indeed do need to know.
    e.g. if he was using an arm-based architecture instead of geode, the masm/nasm-toolchain wouldn't have worked.

  10. #10
    Join Date
    Oct 2006
    Location
    Melbourne
    Posts
    743
    Excellent point Comic, I made the (perhaps) foolish assumption that the code was to be run on an x86 based server, on account of the data being retrieved from a System Management Bus. Rep++ from me mate.
    Last edited by enhzflep; 06-06-2008 at 06:35 AM.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •