CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2018
    Posts
    5

    Understanding controlling Register bits

    I am trying to learn how to make a library out of a datasheet. I am doing alright as far as understanding what to do. Read the address, modify the bits, and write the data back to the address. My issue comes into certain register values and how exactly I am modifying it. I am familiar with bitwise operations and regular 0 vs 1 I understand. The datasheet I am working on is a simple OV7670. Maybe I am overreaching but I really enjoy learning things that I cannot currently do. I am wondering if anyone knows of some useful articles, books etc. on how I learn what whats going on here. datasheet is included. I am having a hard time understanding the HREF register (HREF, HSTART, HSTOP). I understand that I need to change some of these bits. but why and which ones?

    the default values are
    HREF - 0x80
    HSTART - 0x11
    HSTOP - 0x61

    and the example library changes these to
    HREF - 0xB6
    HSTART - 0x13
    HSTOP - 0x01

    there is a note that these values don't make much sense in the code. but I dont understand why they even changed it. I am lost when it comes to these registers as they are not simple enable or disable. I am just looking for someone to point me in the right direction as I am at a wall with this. I also have trouble understanding the HREF control where it states bits[2:0] HREF start least significant bit(HIGH MSB at register HSTART) it goes on with more statements of the LSB and MSB but I really am not understanding what I am changing here. I know what HREF is. but not how it accomplishes it and when its modified what changes and why. I know the you must read the digital pins when HREF is high. and the rising edge is the start and the falling edge is the end. Just some good documentation would get me moving again, any help is appreciated.

    https://www.voti.nl/docs/OV7670.pdf


    Thank you

  2. #2
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Understanding controlling Register bits

    For which system - Arduino?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Mar 2018
    Posts
    5

    Re: Understanding controlling Register bits

    Most likely I would use an arduino to begin with, but I know that the arduino does not have enough memory and this needs to be handled specifically. However, at this stage I am just trying to understand the information so I can implement the library to whatever board. for example, a raspberry pi with an external oscillator. I can change the data just fine but cannot figure out whats going on when changed.

  4. #4
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Understanding controlling Register bits

    If for an Arduino, there's quite a bit of info about this on the Internet. Consider

    http://forum.arduino.cc/index.php?topic=159557.0 and its links.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    Mar 2018
    Posts
    5

    Re: Understanding controlling Register bits

    Yea, unfortunately I have read all of this. This forum post is really the best one out there. I am really stuck as far as what this 8bit number is doing. lets say I have 10000000 as this is the default. what happens if I change it to 01111111? I am not even sure that it does anything as the datasheet does say much. Do you know of any good documentation on advanced register control? I think that might be my best bet other then just changing it but I am not sure that will help, probably just confuse me more haha.

    I am not sure what the description means. other than least significant bit and most significant bit. Its really got me in a brain funk as I was moving so smoothly on this until this one thing.

    anyway thank you for your assistance.

  6. #6
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Understanding controlling Register bits

    Sorry, I've never actually used this device.

    It looks like the horizontal frame position is an 11 bit number. The starting horizontal frame position (11 bits) is a combination of the value of HSTART (high 8 bits) and the 3 low bits are bits 0, 1, 2 of HREF. The ending horizontal frame position (11 bits) is a combination of the value of HSTOP (high 8 bits) and the 3 low bits are bits 3, 4, 5 of HREF.

    Vertical frame is similar - except that it is a 10 bit number. For vertical frame start, VSTART is the high 8 bits and the 2 low bits are bits 0, 1 of VREF. For vertical frame end, VSTOP is the high 8 bits and the 2 low bits are bits 2, 3 of VREF.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7
    Join Date
    Mar 2018
    Posts
    5

    Re: Understanding controlling Register bits

    now what is happening when I change that 11 bit number (sorry I had written 8). For example the gain register if I change the value it will adjust the gain. I know HREF indicates active pixels. and it would appear that this 11 bit number points, in some way, to the 640 pixels. but there is not enough information to understand how. Is the starting horizontal frame position set by the decimal number that is stored in the reg? i.e. if the value of the 11 bit number is 13. does that mean that HREF will begin on the 13th pixel?

  8. #8
    Join Date
    Mar 2018
    Posts
    5

    Re: Understanding controlling Register bits

    thank you for trying to assist. it would seem that this forum needs some extra action and users. I will keep an eye out for things I can assist with.
    Last edited by SyberGrimes; March 17th, 2018 at 10:41 AM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured