LPC1769 SSP/SPI not working with BMA180

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1769 SSP/SPI not working with BMA180

1,119 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RobinHuisman on Thu Jul 21 06:22:17 MST 2011
I am trying to let a LPCXpresso LPC1769 communicate with a Bosch BMA180 accelerometer breakout bord from SparkFun.
But almost everything I send, is echoed back.
When I send 0x80, I get 0x80 back.
Sending 0x81, receiving 0x81.
But when I send 0x83, I get 0x82 back.

I read somewhere that the SDI and SDO pins of the BMA180 could be shorted, so I emailed SparkFun and they sent me a new one. But now I'm having the same problem again.

Do I have bad luck with the hardware of could it be a software problem?

My messy code is in the attachment.
0 Kudos
16 Replies

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sun Jul 31 06:13:44 MST 2011
Yes, SPI is working like a shift register. No clock, no shifting :)
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RobinHuisman on Sun Jul 31 05:47:15 MST 2011
Thanks everyone, I think I have solved the problem.
I had to send dummy bytes while receiving to provide the clock signal.
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Jul 30 13:48:40 MST 2011
Google ?

http://code.google.com/p/keadrone/source/browse/trunk/firmware/SimpleDemo/HAL_SPI/main_spi.c?r=41
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sat Jul 30 13:38:13 MST 2011
If you send me a BMA180 and export your projects I'd be  happy to help you out :D

Rob
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RobinHuisman on Sat Jul 30 13:09:18 MST 2011
Done more testing, but no success.

Does anyone have any suggestions?
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RobinHuisman on Tue Jul 26 04:46:34 MST 2011
I would have to send 0x83, I guess?
Then I'm getting 0x82 back, like in the startpost.
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Tue Jul 26 02:32:30 MST 2011
Hello Robin,

in the BMA180 one location is fixed, which is the ID-number (see page 54 of the datasheet) 0x03.

Can you try to read that ID-number?
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RobinHuisman on Sat Jul 23 11:51:12 MST 2011
Here are the connections:
BMA180:
Vio - 3V3
SDI - P0[18]
SDO - P0[17]
SCK - P0[15]
CS - P0[16]
GND - GND
Vdd - 3V3

XBee:
Vcc - 3V3
Dout - P0[1]
Din - P0[0]
GND - GND

In the attachment is a photo of all the connections.
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Sat Jul 23 09:54:03 MST 2011
Hello Robin,

can you show us the electrical schematic.

Sometimes unpredictable behaviour find its cause in the electrical design.
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RobinHuisman on Sat Jul 23 04:24:16 MST 2011
I've tried some different settings, but I'm getting strange results like 0x04, 0xBD and 0xBF.
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Fri Jul 22 22:51:25 MST 2011
Unfortunately Nijmegen is too far away from Groningen, the cables from my Logic Analyzer are not that long

CPOL/CPHA - good thing to check ...

I got confused by your #defines for these things.
void SSP_ConfigStructInit(SSP_CFG_Type *SSP_InitStruct)
{
    SSP_InitStruct->CPHA = SSP_CPHA_FIRST;
    SSP_InitStruct->CPOL = SSP_CPOL_HI;
    SSP_InitStruct->ClockRate = 1000000;
    SSP_InitStruct->Databit = SSP_DATABIT_8;
    SSP_InitStruct->Mode = SSP_MASTER_MODE;
    SSP_InitStruct->FrameFormat = SSP_FRAME_SPI;
}
The clock should be high in between transactions (CPOL = 1) and data is latched by the BSA180 on the rising edge, being the 2nd edge so CPHA = 1 too.

Compare the lpc17xx User Manual page 418, figure 80 with pag 60, figure 17 of the BSA180 data sheet.

I think the init should contain:
    SSP_InitStruct->CPHA = SSP_CPHA_SECOND;
    SSP_InitStruct->CPOL = SSP_CPOL_LOW;
Regards,

Rob
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Fri Jul 22 16:25:31 MST 2011
Hello Robin,

Did you check the CPOL and the CPHA? Is it programmed as specified in de BMA180 chip?

Remark: in the Sparkfun design the decoupling capacitors are 0.22 nF ... in the Bosch datasheet the suggested value should be 22nF ... Please check.

(...)
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RobinHuisman on Fri Jul 22 13:14:22 MST 2011
I live in the southeast of Groningen.

EDIT: I've just done a test with a transistor inverter and it's working.
When I send 0xF0, I get 0x0F back. Sending 0x80, receiving 0x7F.

So I think it's a hardware problem again...
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Fri Jul 22 11:58:48 MST 2011

Quote: RobinHuisman
Would an inverter made of a transistor and some resistors also work?
I haven't got an oscilloscope or a logic analyzer.



Sure, any inverter would work as long as it is fast enough - or your clock slow enough

Where are you located in the Netherlands? I have both a scope and a logic analyzer.

Rob
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by RobinHuisman on Fri Jul 22 10:24:29 MST 2011
Would an inverter made of a transistor and some resistors also work?
I haven't got an oscilloscope or a logic analyzer.
0 Kudos

1,028 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Thu Jul 21 14:49:37 MST 2011
There is an old Dutch saying: "Meten is weten, gissen is missen".
In English this translates into "To measure is to know, to guess is wrong".

I suggest that you get an oscilloscope or logic analyzer to determine what the signals are.
If you have no access to one of those, you can of course always write a small software implementation of the SPI protocol so you can single step and measure with a simple volt meter.

You could also try to ty the MISO wire to ground (remove from BMA180 when doing this) or place an inverter like a 74HC04 in between MISO and MOSI (the output of the inverter goes to the MISO pin). This way you should see either 0x00, 0xff or the inverted value of what you send.

I've looked at the code and at least the most obvious error (using loopback mode) is not the case ...

Rob
0 Kudos