• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "My brain hurts. I'm supposed to know this stuff."

Collapse

  • Bunk
    replied
    Originally posted by Platypus View Post
    Here's another question - why are you doing this?
    It beats murdering HR people.

    Or does it?

    Leave a comment:


  • zeitghost
    replied
    Originally posted by VectraMan View Post
    What Doodab said. y is accumulating the unused lower order bits so that every now and again it'll add one to the higher order bits that are used. Without it, a stream of 0x0080s would only ever send zero to the hardware and the signal is discarded; with it you get alternating 0x00 and 0x01s.
    A sort of dithery thing then.

    Interesting.

    Leave a comment:


  • zeitghost
    replied
    Originally posted by Platypus View Post
    Here's another question - why are you doing this?
    It marginally relieves the tedium.

    Leave a comment:


  • Platypus
    replied
    Here's another question - why are you doing this?

    Leave a comment:


  • zeitghost
    replied
    One assumes that the caller is putting whatever data needs to be written in the high order byte.

    I still can't get my head around this.

    Here's another question:

    Problem 3—What is the difference between an
    interpreter and a compiler?


    Slight difference in level, what?

    Similarly:

    Problem 1—Why is it a generally a bad idea to
    write lengthy ISRs?

    Leave a comment:


  • VectraMan
    replied
    What Doodab said. y is accumulating the unused lower order bits so that every now and again it'll add one to the higher order bits that are used. Without it, a stream of 0x0080s would only ever send zero to the hardware and the signal is discarded; with it you get alternating 0x00 and 0x01s.

    Leave a comment:


  • zeitghost
    replied
    Yes, but why?

    If the DAC is connected to bits 8 to 15, wtf does y have to do with owt?

    Some of those EQ questions are mind bending.

    But only if you don't know the answer, like.

    Plus there's no way to find the answer now since the question was posed about 13 years ago.

    Leave a comment:


  • Platypus
    replied
    Ah got it. Because it's an 8 bit DAC, you maintain the lower at bits at 0x8000 and only change the upper bits.

    Badly explained but I know what I mean

    Leave a comment:


  • stek
    replied
    Why don't you just tippex it out?

    Sometime you have to think around a problem...

    Leave a comment:


  • doodab
    replied
    y appears to be keeping track of the low order part of the result of cumulative addition of x to itself. Presumably something to do with keeping the result accurate over many iterations because the value of x is truncated when it's written to the DAC?
    Last edited by doodab; 25 June 2013, 14:46.

    Leave a comment:


  • Platypus
    replied
    Weird, y remembers the last value of x therefore you can switch bits on but not switch them off again, since y is added to current x.

    Leave a comment:


  • zeitghost
    started a topic My brain hurts. I'm supposed to know this stuff.

    My brain hurts. I'm supposed to know this stuff.

    Problem 3—An embedded 16-bit microcontroller is connected to an 8-bit DAC, where the DAC is connected to
    the high-order half of the data bus.

    What is the purpose of y in the following driver?

    Code:
    #define DAC (*(unsigned *) 0x8000)
    void DAC_out (unsigned x)
    {
    static unsigned y;
    x += y;
    y = x & 0x00FF;
    DAC = x;
    }
    WTF?

    I haven't a clue.

    It's part of an EQ test out of circuit cellar issue 119.
    Last edited by zeitghost; 25 June 2013, 13:30.

Working...
X