Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
871 Views

DE0-Nano-SoC G-Sensor without Linux

My intention is to make a level sensor using to LEDs and the G-Sensor on the DE0-Nano-SoC. When I tilt my board to the left, the LEDs towards the left should glow and so on. 

 

I want to use the G-Sensor using a simple assembly program written for Nios II. The user manual says that the G-Sensor can be used by Nios II by using a particular base address. How can this be done and what are the registers available that I can make use of to access the accelerometer with a simple assembly program? There is a tutorial that uses Linux. It puts the Linux OS on the SD card and then uses the Accelerometer. I believe that becomes a very round about procedure.  

 

In case I can use the G-Sensor using Nios II, do I need to take care of the timing in the I2C protocol or will the I2C controller take care of it? Please do give me a list of the registers available and their addresses. Also tell me the procedure to make use of those registers.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor I
51 Views

According to the block diagram of the board, the G-Sensor is attached to the HPS/ARM side of the SoC. You will need to write your code for the ARM. If your code is small enough, you can add it to the preloader. If not, you can have the preloader load it for you. I.E. your code replaces the uboot that loads Linux. You can find information on the HPS I2C controller in volume 3 of the cyclone 5 handbook. Register info is available on the same page as the handbook download.

Altera_Forum
Honored Contributor I
51 Views

Yes, Nios will be perfectly capable of hosting the I2C interface to the G-sensor. However, Nios is a soft core processor that sits in the FPGA fabric. The DE0-Nano-SoC features a Hard Processor System (HPS). This is very different to Nios. 

 

 

--- Quote Start ---  

There is a tutorial that uses Linux. It puts the Linux OS on the SD card and then uses the Accelerometer 

--- Quote End ---  

This will be running Linux on and hosting the accelerometer from the HPS. You suggest this is a round about way of doing it. It simply means you'll be running your software on the HPS rather than Nios. Whilst there are huge processing benefits from this (which you don't need) and it supports I2C natively, it's another set of tools to understand. You will also have to interface to the FPGA fabric, from where the LEDs are hosted, to control them. 

 

You can do what you're suggesting, on that development kit, using Nios. However, as the I2C interface is hosted from the HPS you'll need to map that peripheral to the fabric, where your Nios will be. This App Note: mapping hps ip peripheral signals to the fpga interface (https://www.altera.com/content/dam/altera-www/global/en_us/pdfs/literature/an/an706.pdf), describes how to do this. You'll also have to implement the I2C peripheral yourself or buy/use a third party one - Nios doesn't come with one. 

 

Assuming you're familiar with Nios then I suggest you go that route. As for a 'procedure to make use of those registers', that'll depend on how you implement the Nios I2C peripheral. 

 

Cheers, 

Alex