• 0

Question

Hi was trying to interface the accelerometer available on the nexys 4 board. But i was not getting any data. Then I mapped the output pins to the JA PMOD header so I could probe them

Using an logic analyzer I saw that the sclk and Chip_select were working but the MOSI signal is full of zeroes.

I connected an 50MHz clk coming from the clock wizard, and then connected it to the ext_spi_clk and used an scale of 16 so the clk is about 3.16MHz

 

Below is the Block_Design

image.thumb.png.25d6ec7e0187519ae837e50d536612ea.pnghelloworld.c

Below is the data I acquired using saleae logic analyzer:

 

image.thumb.png.a16d0202d4cdfd0c168261d344268f39.png

 

I submitted the C files containing the main (helloworld.c) wich is a almost linear copy of the polled example;

The accelmacros file has some values with the commands and register addressees of the SPI slave.

Do you have any hint of what I am missing?

Thanks in advance.

accelmacros.h

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello @dfdias,

I don't see anywhere that you set the SPI mode. According to ADXL362 datasheet the SPI timing scheme follows CPHA = CPOL = 0, so it's mode 0.

You should set the options accordingly:

 u32 options = (XSP_MASTER_OPTION | XSP_CLK_ACTIVE_LOW_OPTION ) | XSP_MANUAL_SSELECT_OPTION;
 XSpi_SetOptions(&AD_Sensor,options);

Let me know how it works!

Share this post


Link to post
Share on other sites
  • 0

Hum ok I will try. That actually makes sense, although when opened a debug session I saw that the register containg cpha and cpol was as it should be.

Thanks in advance.

I will reply as soon as I test it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now