help reading adxl312


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: help reading adxl312

    Ok, first my apoligies, you should have gotton 1 hz with the code I posted. NOT 60 Hz. if the LED never turned off, well that is confusing. Maybe a typo somewhere?

    On to more important stuff. with your code as posted (pause 250) you should get 2 hz. Is that what you are getting? pause 250 equals 2 Hz with OSC 20? If this is so, then I think you need to have OSC 20 as your define. Heres why I know:

    pause uses OSC define to generate delays in software based on the OSC value. So when OSC matches actual pic speed the pauses will be the correct amount of time. 250 mSec on then 250 mSec of is 2 Hz.

    So assuming make sure your DEFINE OSC is correct. Of course that doesn't address the fact that you say you get junk from serout when OSC is 20.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Jul 2011
    Posts
    21

    Default Re: help reading adxl312

    sorry i messed up the test results, this is the result i got, tested it twice

    test program
    test:
    high porta.0
    pause 500
    low porta.0
    pause 500
    goto test

    result at osc 48
    led on off duration is exactly 1 second

    result at osc 20
    led on off duration is twice

    so i think define osc is correct.

    i found this code(in document section) from sparkfun:http://www.sparkfun.com/products/9814
    it is for adxl345 and uses spi but its in c and for atmega..

  3. #3
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: help reading adxl312

    Well I am sorry it wasn't as simple as the clock being wrong, But now you know how to test it. I actually do this on all my programs before going any further just to verify the clock/osc and me are all at the same speed.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default Re: help reading adxl312

    The SHIFTOUT command sends 8-bits unless otherwise specified.
    To send a 16-bit constant, you'll need to specify the number of bits.

    shiftout data_out, CLOCK, 2, [%0011000100100000\16]
    DT

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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