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
  • Challenges & Projects
  • Design Challenges
  • Path to Programmable
  • More
  • Cancel
Path to Programmable
Blog Path to Programmable - Project update - I made something!
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: aspork42
  • Date Created: 11 Jan 2019 5:49 AM Date Created
  • Views 3004 views
  • Likes 9 likes
  • Comments 17 comments
  • isr
  • interrupt
  • pwm
  • xilinx
  • fpga
  • vivado
  • sdk
Related
Recommended

Path to Programmable - Project update - I made something!

aspork42
aspork42
11 Jan 2019

Well - I finally managed to do it!

I have created a basic project based on the lessons from the training.

image

 

About:

Through Avnet, Xilinx and Element14, a training program to learn about the Zynq 7000 platform which is System On Chip combining an FPGA with an ARM processor. This comes to the students as complete development board packed with goodies like a wireless chip from MuRata (BT/BTLE/WIFI), 8GB Flash memory, onboard RAM, USB to JTAG (JTAG programmable over USB), Arduino-style headers (3.3V compatible only), Microphone, Bi-Color LED, and two additional expansion ports.

 

See all blog posts for this training here.

 

What did I do?

My project was supposed to be a line follower, but I had to limit the scope to just the sensor array as I talked about in the previous blog post. I spent a number of days trying to run with external hardware using an ADC to read the line sensor array; but for the life of me, I couldn't get the I2C bus to work. I continually got compiling errors in SDK relating to an interrupt library:

 

fatal error: xintc.h: No such file or directory

 

I wasn't able to find any example code that I could start with as a base.

 

My project ended up being an Timer Interrupt library based in the FPGA fabric. It generates an interrupt every "N" clock cycles; and I mapped it to the 48 MHz clock. This interrupt then feeds into the interrupt concatenator as interrupt #0. This still is relative to what I had wanted to do, but much much farther away from where I wanted to be.

 

I used the IP Library to find new IP and import into my hardware design. I then exported the hardware and made a new workspace & BSP in the SDK utility. I started with some base code in the SDK and got it working with my new hardware to run things. So I'm using both the PS + PL. I had to re-map the interrupt which was used in the base program to the one generated from Vivado.

 

image

 

 

This project uses the PWM LED dimmer as a base code for the PS side of things; but modified. When the FPGA Fixed Interval Timer ("FIT") generates an interrupt, it is captured in the PS running my code. We keep count of the number of interrupts and use that to run the PWM signal back out to the real world.

 

Here is the functional part of the ISR that does it:

 

void PWMIsr(void *InstancePtr)
{
count += 1; // add one to the counter
brightness = (count % 10)* 110000; // count modulus 10, multiplied by 110000 to normalize with the clock
xil_printf("\033[2K I have been interrupted %u times! Setting brightness to %u \r", count, brightness);
Xil_Out32(PWM_BASE_ADDRESS, brightness);//write value to PWM controller back in the PL
}

 

This code is still related to the project I wanted to do. I spent hours trying to create the part of the line follower which reads a wheel encoder and provides feedback about the speed of the robot before I settled on this as a start. Since this has a consistent time-based interrupt, I could use it to periodically check a counter to calculate the frequency of pulses; which correlate to speed. The output of this would then feed into a PID loop to adjust the PWM signal going out to the wheel motor based on the speed delta.

 

I can say that this has been very tough challenge as I don't have any background with FPGAs. Although this project is hardly earth shattering in terms of complexity, but it does demonstrate that the training has actually given a total beginner enough knowledge to perform some basic tasks. As stated above, this does make use of both the PS + PL, and both Vivado and the SDK were required to make all of this work. I had to find & import IP on my own, re-wire the block diagram, export a valid bitstream; then import to SDK and write [well, ok, 'modify'] a corresponding program. I have gotten much better at navigating the interfaces now that I'm doing it on my own. I decided that I like the automatic build when you save a file in SDK. One other nice thing as stated in a previous blog was the System Debugger lets you edit code and upload right from the deugger; which made it much faster and easier to develop. I thought at first that this would be annoying; but when running the debugger I can edit code right there, hit save (which generates a new build) then restart the deubgger immediately. I'm really curious what shortcuts are available on this platform to speed up hardware debugging because using the FPGA side to alleviate pressure on the ARM processor would be amazing and key to the line follower that I would like to build with this.

 

I found myself numerous times falling into some of the traps that the training warned about - importing code incorrectly, leaving a space in the Application Project Name (see cryptic error message below), and many other things. I would start getting cryptic errors and after an hour or so of troubleshooting, I would realize my mistake.

 

Error message from invalid application project name. This doesn't show up until one tries to run the debugger.

wrong # args: should be "dow ?options? file ?address?"

 

As with the Smart Range Hood design challenge, my sympathetic wife hung in there watching our two kids while I hid away in the workshop on this project, so I owe a big thanks to her.

 

See the video here to watch it in action! (sorry about the background noise with my 3D Printer running)

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Conclusions?

What did I learn from this? What are the take-aways?

Well... as far as the actual training documents, they are very well written. As long as someone can follow them, they can complete the lessons. There are training videos which are pretty dry and the presenter can be seen reading the prompter which was pretty distracting; but otherwise were very good. Looking back, I think I would have preferred having the SW (SDK) lessons first, then introduce the Hardware lessons and Vivado. The reason is that, especially for someone new to all of this, things can get overwhelming. As we modify the hardware in Vivado, there are quite a few steps required to get it running on the actual board - Synthesize, generate Bitstream, Export. Open SDK, Import hardware and generate Board Support Package. Create a new application (even it it is an empty 'do nothing' app), THEN we can program the FPGA, Then we have to run the application.

 

With this board, The FPGA (PL) can't run without at least a generic PS program. If we had done the software training first, then at least I would have been more comfortable with the SDK before I get in a start with the FPGA stuff. But then again, part of the focus of this training was around using an FPGA, so doing training in that order does seem a little backwards, and also means we couldn't write FPGA programs until the second half.

 

A huge thanks to Xilinx, Avnet, and Element14 for sponsoring this contest! I plan to continue to develop more with the MiniZed and really let it flex its muscles.

 

- James O'Gorman

  • Sign in to reply

Top Comments

  • michaelkellett
    michaelkellett over 6 years ago +6
    Thanks for your work so far James. Sorry you couldn't get the I2C to work the way you wanted. From your efforts and those of the other reviewers I still think the Zynq is far to hard to use to gain the…
  • aspork42
    aspork42 over 6 years ago in reply to michaelkellett +2
    Thanks Michael - Yes - there was a pretty big learning curve on this one. I certainly understand where the complexity comes from, but after working with things like Arduino for so long I come to the MiniZed…
  • nixiefairy
    nixiefairy over 6 years ago +2
    Good job James! And congrats on completing the course ! I doubt I can finish mine in time
  • mu.udhay
    mu.udhay over 6 years ago in reply to aspork42

    Very Happy to see it Talking image , Have the Joy of Playing with Minized image !

    I too Started Building my Project  using USB host image ...

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • aspork42
    aspork42 over 6 years ago in reply to mu.udhay

    We have contact!

    Yahoo! Thanks for the sample code - this worked a treat. It is pretty much what I was expecting but didn't find from the SDK sample library. Below is the log readout and a scope trace of the clock and data bus. I can  now use this sample to read from the ADC and hopefully get what I'm looking for image

     

    Thanks again!

     

    With I2C device address 0x1d received WhoAmI = 0x43ghtness to 770000
    CTL1 = 0x60 written
    CTL4 = 0x01 written
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +184, Y:                              +394, Z: +4078
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +183, Y:                              +395, Z: +4068
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +186, Y:                              +417, Z: +4091
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +177, Y:                              +409, Z: +4109
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +187, Y:  +396, Z: +4078
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +174, Y:  +400, Z: +4072
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +186, Y:  +405, Z: +4067
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +177, Y:  +400, Z: +4096
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +159, Y:  +405, Z: +4071
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +174, Y:  +407, Z: +4054
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +178, Y:  +405, Z: +4080
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +161, Y:  +400, Z: +4057
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +178, Y:  +414, Z: +4070
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +168, Y:  +405, Z: +4087
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +177, Y:  +395, Z: +4069
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +175, Y:  +383, Z: +4050
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +174, Y:  +410, Z: +4067
    OUT_T register = 0x0b -> Temperature = 36 degrees C  Acceleration = X:  +179, Y:  +401, Z: +4067

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • aspork42
    aspork42 over 6 years ago in reply to mu.udhay

    Thanks for the reply and the code sample. I had started down the path of replacing the library with xscugic.h and found that all the calls had to change also and wasn't sure how far I should go with it. I have downloaded the code from your Github and will try it later this week. I'm traveling this week - I am from Milwaukee, WI and am in Indianapolis today and Chicago on Friday.

     

     

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mu.udhay
    mu.udhay over 6 years ago in reply to aspork42

    I found the problem,actually it is not simple to explain because the Example code is based on ML300 board , they used : #include "xintc.h" where as we need to use #include "xscugic.h" for Interrupt Controller

    Similarly we need to modify a number of Macro and Calling Functions such as:

    Given                                                             Needed to be Replaced By

    XPAR_INTC_0_DEVICE_ID                    XPAR_SCUGIC_SINGLE_DEVICE_ID

    XPAR_INTC_0_IIC_0_VEC_ID               XPAR_XIICPS_0_INTR

    XIntc InterruptController                         XScuGic InterruptController

    and soon.....

    then we need to change the functions with the parameters based on the prototype , thats why i said it is bit complex.

     

    But don't worry , i got a simple standalone i2c program for minized to get temperature and axelerometer data,i uploaded it my git here:

    https://github.com/uElectron/minizedSDK/tree/master/using_I2C

     

    I figured out what needed to do to implement Interrupt based program,i would try to make a video regarding how to write and use i2c soon.

    If you have any problem or doubts feel free to post image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • nixiefairy
    nixiefairy over 6 years ago in reply to aspork42

    Hi James,

    I am answering to the best of my ability so don't go by my word. I think the libraries we import on SDK are used to generate (compile) the .elf object file which is then loaded onto the board (or here the ARM Cotex A9) . In Vivado, we can manage different settings and connections of a Zynq block design to generate a .hdf and bitstream. In other words, just the hardware specification. The BSP contains the libraries required to program the various IPs in design. So to me, I think it's a SDK compilation problem.

    Next you will have to import the header file so that it can be used to compile to the program on SDK. For this did you add the header file to the path set by the environment variable in SDK? Select the project and go to File > Properties > C/C++ General > Paths and Symbols. I think from there you should be able to figure it out .

    Eashan

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
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