element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Path to Programmable 3
  • Challenges & Projects
  • Design Challenges
  • Path to Programmable 3
  • More
  • Cancel
Path to Programmable 3
Blog Interfacing LMS6DSL Click Mezzanine with Ultra96-V2 Using Vitis - Blog 4
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Path to Programmable 3 to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: rahulkhanna
  • Date Created: 5 Sep 2023 7:42 PM Date Created
  • Views 614 views
  • Likes 4 likes
  • Comments 0 comments
  • ultra96v2
  • design challenge
  • vivado
  • Ultra96-V2 Board
  • Path to Programmable III
  • Path to Programmable 3
Related
Recommended

Interfacing LMS6DSL Click Mezzanine with Ultra96-V2 Using Vitis - Blog 4

rahulkhanna
rahulkhanna
5 Sep 2023
Interfacing LMS6DSL Click Mezzanine with Ultra96-V2 Using Vitis - Blog 4

In this tutorial, we will guide you through the process of interfacing the LMS6DSL Click Mezzanine with the Ultra96-V2 development board using Xilinx Vitis. The LMS6DSL Click Mezzanine is equipped with a sensor that can measure both acceleration and angular rate, making it a versatile choice for various applications. We will read sensor data and integrate it into the Ultra96-V2 projects. Let's get started!

Create a New Vitis Application Project

  1. Launch Xilinx Vitis.
  2. Create a new Vitis application project.
  3. Select your Ultra96-V2 board as the target platform.
{gallery}
image

image

image

Create an application project for the LMS6DSL sensor and add the following C code to read data from the LMS6DSL sensor. We will be using the SPI interface to communicate with the sensor. Build the project and program the Ultra96-V2 board with the generated application.

#include "xparameters.h"
#include "xspips.h"

#define SPI	  XPAR_XSPIPS_0_DEVICE_ID
static XSpiPs SpiInstance;

int main()
{
	XSpiPs_Config *SpiConfig;

	int delay;
	s16 temperature;
	u8 cmd[2];
	u8 rx[2];
	u16 temp;
	u8 temp_l;
	u8 temp_h;
	u8 read = (0x80);
	u8 write = (0x00);
	int byte_i;
	int loop;

    printf("Lab 11\n\r");

    SpiConfig = XSpiPs_LookupConfig((u16)SPI);
    XSpiPs_CfgInitialize(&SpiInstance, SpiConfig,SpiConfig->BaseAddress);
    XSpiPs_SetOptions(&SpiInstance,XSPIPS_MASTER_OPTION |  XSPIPS_FORCE_SSELECT_OPTION);
    XSpiPs_SetClkPrescaler(&SpiInstance, XSPIPS_CLK_PRESCALE_256);

    //detect the LSM6DSL
    cmd[0] = (u8) 0x8f;
    cmd[1] = (u8) 0x00;
    XSpiPs_SetSlaveSelect(&SpiInstance, 0x01);
    XSpiPs_PolledTransfer(&SpiInstance, cmd, rx, 2);
    XSpiPs_SetSlaveSelect(&SpiInstance, 0x01);
	if (rx[1] == 0x6a){
		printf("LSM6DSL detected\n\r");
	}
	else{
		printf("LSM6DSL NOT detected cannot continue\n\r");
		return XST_FAILURE;
	}

	cmd[0] = (u8) 0x10;
	cmd[1] = (u8) 0xA0;
	XSpiPs_SetSlaveSelect(&SpiInstance, 0x01);
    XSpiPs_PolledTransfer(&SpiInstance, cmd, rx, 2);
	XSpiPs_SetSlaveSelect(&SpiInstance, 0x01);

	while(1){
	cmd[0] = (u8) 0xA0;
	cmd[1] = (u8) 0x00;
	XSpiPs_SetSlaveSelect(&SpiInstance, 0x01);
    XSpiPs_PolledTransfer(&SpiInstance, cmd, rx, 2);
	XSpiPs_SetSlaveSelect(&SpiInstance, 0x01);
	temp_l = rx[1];
	//printf("Temp L %x\n\r",rx[1]);

	cmd[0] = (u8) 0xA1;
	cmd[1] = (u8) 0x00;
	XSpiPs_SetSlaveSelect(&SpiInstance, 0x01);
    XSpiPs_PolledTransfer(&SpiInstance, cmd, rx, 2);
	XSpiPs_SetSlaveSelect(&SpiInstance, 0x01);
    temp_h = rx[1];

	//printf("Temp H %x\n\r",rx[1]);

	temp = ((temp_h <<8)|(temp_l));

    if ((temp & 0x8000) == 0) //msb = 0 so not negative
    {
    	temperature = temp;
    }
    else {
    // Otherwise perform the 2's complement math on the value
    temperature = (~(temp - 0x01)) * -1;
    }
    //printf("Temp %x\n\r",temperature);
    temperature = temperature * 0.09765;
    printf("Temp %d\n\r",temperature);
	usleep(1000000);

	}
}

Turn off the board and connect the LMS6DSL Click Mezzanine to the Ultra96-V2 board. Make sure it's securely attached to the board's Click Mezzanine connector.

image image

image

Congratulations! We've successfully interfaced the LMS6DSL Click Mezzanine with the Ultra96-V2 development board using Xilinx Vitis. You can now integrate sensor data into your Ultra96-V2 projects. Happy coding!

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube