CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Tap sensing with BMA180 accelerometer

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Tap sensing with BMA180 accelerometer
PostPosted: Fri Jun 29, 2012 10:47 am     Reply with quote

Folks,

By any chance, does anyone have a code snippet, which would show how to initialize BMA180 accelerometer for tap sensing? Doesn't matter whether it's SPI or I2C, I should be able to adapt it to my setup.

So far, I was able to communicate with my BMA180 via SPI. I can read chip ID, accelerations. I can set up a new data interrupt, and it behaves as expected.

When I try to set up the tap sensing interrupt, the INT pin goes high without tapping and stays high. I've added code, which resets the interrupt every second, but the pin immediately (within 0.5ms) goes back high. I guess, somehow the BMA180 thinks that it's tapped all the time.

Here are my present settings:
    interrupt is latching
    range: 2g (default)
    tap duration: 500ms
    tap threshold: 254
    the rest are default


Any suggestion, insight or reference is really appreciated!

Cheers,
- Nick
_________________
Read the label, before opening a can of worms.


Last edited by kender on Sat Jun 30, 2012 2:46 pm; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9162
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jun 29, 2012 3:47 pm     Reply with quote

obvious comments are ...
have you downloaded any relevant documentation and test code from the OEM ?
googled to see what's out 'there'? I got a few thousand hits including code(though not CCS C), code is code.

You say you have the sensor configured to latch the interrupt so what resets it ?
Since I don't have that sensor, I can't cut code but as you have it working I suggest it's something in the setup, either the config or a timing(sampling) problem.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Fri Jun 29, 2012 8:18 pm     Reply with quote

Obvious response to your comments: Please don't assume that I'm stupid. Do me such a favor.
... and you're always welcome to post something that is not completely useless. That is, less useless than ballpark number of hits on google.

temtronic wrote:
have you downloaded any relevant documentation and test code from the OEM ?

Besides datasheet (which I have), what other documentation would you refer me to?

temtronic wrote:
googled to see what's out 'there'? I got a few thousand hits including code(though not CCS C), code is code.

Indeed, there is sample code for BMA180 on the web. It was useful for making other functions in the BMA180 work. I couldn't find sample code for tap sensing, though.

temtronic wrote:
You say you have the sensor configured to latch the interrupt so what resets it ?

I've mentioned this in the O.P. Please read.
_________________
Read the label, before opening a can of worms.
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Sat Jun 30, 2012 2:19 am     Reply with quote

Thing is Kender, that this is a help forum, for _CCS code_, not for general 'how to get something to work'. Unfortunately it suffers from rather a lot of abuse, and in particular from people doing projects who seem to want the posters here to write complete code for them. Hence some people have become a bit 'short tempered' about posts that are perhaps too open sounding.

Looking at the chip, you do realise you need to turn _off_ the other possible interrupt sources?. The chip internally "OR's" the interrupt sources, so if any of the other bits are set, you may get a 'conversion complete' interrupt setting the pin, and the behaviour you are seeing.

The data is a bit naughty, since it lists the 'power on' values for several of these registers as '0', but then says that they are set by default to values from the EEPROM, with these given on page 26. These seem to be saying that just about every interrupt is _enabled_.....

You need to set all these bits to zero, and read them back, to 'check'.

Best Wishes
temtronic



Joined: 01 Jul 2010
Posts: 9162
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jun 30, 2012 5:21 am     Reply with quote

I don't assume anyone is stupid, heck you got the thing working...but I've found that OEM datasheets may need to be read a few times as different mfrs. say the same thing different ways, or init their chip to some odd config (never the one you want).
OEMs typically have lots of 'application notes' , some might use that chip, though not obvious, and have some tidbit of info (like the wired or setup) that you need to know.
Same holds true of 'googling', It is an amazing tool to use and can save a ton of R&D time. Knowing that the order of the words in 'search' is important can quickly drop the hits from 1000s to 100s.

re: my last comment...
you said...
interrupt is latching

So what I wanted to know is what mechanism 'resets the latched interrupt' on the perhipheral ? Ttelmah says the int is wired 'or, so it appears something else, inside the chip is keeping the int high making it a chip problem NOT a PIC or code issue.

It's all in the 'details' that hopefully the datasheet has.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Wed Jul 04, 2012 8:00 pm     Reply with quote

Ttelmah wrote:
[...] The data is a bit naughty, since it lists the 'power on' values for several of these registers as '0', but then says that they are set by default to values from the EEPROM, with these given on page 26. These seem to be saying that just about every interrupt is _enabled_

Ttelmah, you are spot-on. By default, most interrupts are enabled including new_data_int (aka conversion_complete). When I've disabled them and re-enabled only the tap interrupt, all worked as expected. German part...

P.S. Found the solution myself, then read Ttelmah's post.
_________________
Read the label, before opening a can of worms.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group