FXOS8700CQ have trouble controlling the /CS of the SPI with STM32F4 ... anybody got working ARM source for this :-) ?

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

FXOS8700CQ have trouble controlling the /CS of the SPI with STM32F4 ... anybody got working ARM source for this :-) ?

1,096 Views
joergonfreescal
Contributor II

The controller supports all the signals of the SPI interface without the /CS ... so I do this manually, but I never get a working communication. I tried out various possible options but the data I read makes no sense. Now of course the next thing to do would be to dive into debugging the hardware with a scope but I wondered if maybe somebody has already done that and tell me the right setup or even share a line of code. From what I see on the web it might even be possible that the Freescale eval board uses a similiar processor, but that code does not seem to be public ...

Labels (2)
8 Replies

679 Views
joergonfreescal
Contributor II

OK, here's where it all starts ...

schematic.PNG

which leads to this (the blue lines are not the real layout, just made them by hand just now) ...

board.PNG

so the connections are ...

U16

4    34    PB13    M1_CLK

6    36    PB15    M1_MOSI

7    35    PB14    M1_MISO

9    24    PC4      M1_INT2

10   33    PB12    M1_CS

11   14    PA0      M1_INT1

U17

4    51    PC10    M2_CLK

6    53    PC12    M2_MOSI   

7    52    PC11    M2_MISO

9    25    PC5      M2_INT2

10   50    PA15    M2_CS

11   15    PA1      M2_INT1

Hmm ... wonder how to insert source code ... guess I have to check out the advanced editor ...

0 Kudos

679 Views
anthonyduhamel
NXP Employee
NXP Employee

Hi Joerg,

Regarding your schematic, I suggest you to connect FXOS8700's RES pin to the ground. Capacitors C92/C95 must be short-cut to ensure a low level on the reset pin.

(You can insert source code by copying it in the classic textbox. Then "Use advanced editor", select you copied code and press ">>" in the toolbox. Click on "Syntax Highlighting -> C++").

I don't know if it will fix SPI issue but try it first!

Anthony

679 Views
joergonfreescal
Contributor II

Hi Anthony,

turns out I'm not THAT dumb :-) ... these parts in reality are 0 Ohm "resistors". I now found that I used the second latest version of the schematic above. So that's not the reason, unfortunately. And I already got my hopes up :-) ... I'll post the source as soon as I have it in reasonable shape and tested again.

Thanks for your help ! Very motivating :-) ...

Joerg

0 Kudos

679 Views
anthonyduhamel
NXP Employee
NXP Employee

Joerg,

Okay for 0 ohm resistors! I supposed they has been populated on your pcb !  

I'm waiting for your feebacks. Keep me inform of your project progresses.

Anthony

0 Kudos

679 Views
joergonfreescal
Contributor II

Hello Anthony,

thank you for pointing this out. It's strange ... I have no idea why I put these capacitors there ... checked the docs I used ... no caps anywhere ... :-(.

Either I temporarily confused RST and Crst or I don't know. Really disturbing as I must have checked the schematic a 100 times but that thing was in some kind of a mental blind spot. There must be smarter life forms in the woods :-) ... unbelievable ... OK, thanks again and I'll be back as soon as I know for sure. Have to get rid of all the changes to my software which I made because the correct setup didn't seem to work ... BTW this website changed the capitalization - the nic was supposed to be JoergOnFreescale.

0 Kudos

679 Views
anthonyduhamel
NXP Employee
NXP Employee

Hi Joerg,

Some questions about your Hardware design: is it a point-to-point communication, or are there multiple slaves on the SPI lines? Did you put the SA0/MISO pin to High-Z (High Impedance ) state to enable SPI communication on FXOS8700 at the device start (for at least 1ms )?

Capture.PNG

Software side: Can you share with us samples of your code? To be sure the device is working well, read the WHO_AM_I register. If the returned value fits to the expected one SPI communication should be ok.

Capture.PNG

If not, you should have spi issues...

Thanks,

Anthony

679 Views
joergonfreescal
Contributor II

Sorry Anthony,

reading my answer again I see that I totally missed to thank you for answering. Friday ...what can I say ? I'm very glad you answered !

Have a nice weekend :-),

Joerg

0 Kudos

679 Views
joergonfreescal
Contributor II

Hi Anthony,

yes, you listed the requirements which I checked ten times ... I have two of these sensors on two separate SPI ports of an STM32F405RGT6. Both connections are point2point, single master, single slave. When the controller gets power its periphery pins are tri-state and need to be enabled. That happens just after I load and execute the test program ... many seconds after power up. Until then these pins remain floating. Of course modern controllers always have some protection devices connected to the pins. Hope they don't interfere there ...

Of course the first thing I tried was to read the who_am_I and after not getting the right result later on I decided that maybe I was doing something wrong with the addressing and attempted to write and read back at the current address ... Never got anything reasonable. Frankly this drives me crazzy and thats why I asked if somebody has any working code :-) ...

One major problem is that the ST32F4 software development environment is in such a mess. Obviously over the years they went through endless restructuring and when you seek on the Internet you never know which comment is related to which (former) version of the environment. All the elements that are related to the workings of a certain pin or module are distributed over about 10 files if not more and to some extend they interact with yet other stuff. That's not a topic for this forum but this is by far the worst environment I ever touched and I'm doing this since the 1980s :-(.

As far as I can see there are two things I must achieve - to set up the interface to be an SPI master and to control the /CS manually (which I did not expect to have to do, frankly, unnecessary nuisance). There are 4 possible configurations of the SPI concerning the relation and polarity of the clock and the data. At the beginning I configured it as specified, but since nothing worked in the meanwhile I also attempted the other combinations.

Source ... well ... as mentioned that's all over the place ... I'll have to try and cut and paste for some time to make a reasonable listing and comment it too.

0 Kudos