I'm currently working on the Altera DE0 board with the QuartusII Web Edition software. I need to use a nios processor on Qsys to display a shifted signal from a GPIO pin on my board. The input signal would be a clock signal from an external source. The problem is that I have no idea how I can write a program in C (on the Eclipse IDE) for diplaying a delayed clock on an oscilloscope.
My Qsys design looks like that Image1 => Qsys Design and here the Eclipse IDE where I have to write my C program Image2 => Eclipse IDE
Please help me !
thank you very much in advance for the replies
start with the system.h file to know which base_address is assigned to each peripherial, then you can use pointers to directly access the GPIO or use the IORD/IOWR functions.
Related
I want to reprogram the external flash of a raspberry Pico via SWD line.
This feature must be implemented in a different microcontroller, not from a Linux computer so the OpenOCD library cannot be used.
I already wrote a C library that is able to read and write in RAM and in core registers via SWD and I'm able to put the Cortex-M0+ into halt state.
I read many tutorials and documentation and those that are useful are:
http://markding.github.io/swd_programing_sram/
https://www.silabs.com/documents/public/application-notes/an0062.pdf
https://community.silabs.com/s/article/how-to-program-internal-sram-over-swd?language=en_US
but unfortunately they aren't clear enough.
Can you explain the sequence of commands that I should send to RP2040 to correctly upload the new firmware?
Thanks for your help!
I am trying to write C test code for SPI peripheral module for Pulpissimo.I have gone through the test case mentioned in pulp-rt examples.
[https://github.com/pulp-platform/pulp-rt-examples/tree/master/periph/spim][1]
But I understand that the above code need the support of an external board. I have no board available with me. Is there any way to write test case in C for SPI?
I dont think that you will find a spi emulator supporting c language.
SPI is a 3 wire interfaces using clock/data in / data out (more bits can be used like chip select and others, but basic is 3 pins).
C is a programming language that will generate a binary file, not interpreted, so probably not the best language for a emulator.
The best that you can probably find is a microcontroller emulator that support an oscillator in virtual GPIO pins, but i dont know any.
As Rovert Harvey told you, the best that you can do is buy a board, but you dont need to spend 100 euros, just buy a ESP8266 board with wifi , spi, and other stuff for 2 euros/dollars. Then use arduino ide, they use .ine files that are a light modification of .c files and it supports .c files too.
I am taking Arduino Prototype code used for a DS3231 RTC and taking it to an embedded platform that does not directly support Arduino code (right now that is the Atmel Xplained Mini). Is there a way for me to create an equivalent program without writing an entire I2C protocol and the entire data communication from scratch? There must be an overlapping library/header/code block that I can adapt to my purpose.
As an example I am looking to make the code here work on the Atmel Xplained Board. The code should be pretty simple, what I need is for the DS3231 to tell the MCU the time when it asks for it. I can do the manipulation of the date/time myself, it is getting that information on a non-Arduino platform that is the road block for me.
Arduino has an existing wiring library that facilitates I2C communication, most professional development frameworks aren't quite so simple but are also more full-featured. I'm assuming you are using Atmel Studio, you'll want to look at the TWI (two-wire interface) documentation for doing I2C communication.
AVR315: Using the TWI Module as I2C Master
You can copy TWI_Master.c and TWI_Master.h to your project and use these for I2C communication. That is what I've typically done in the past.
The demo code that goes with this app note can be found here, main.c has an example of the usage of this I2C driver:
AVR315 Demo Code
I am trying to move from arduinos to AVR C. Would somebody know how to remove the arduino bootloader from the microcontroller? Is there a different process for the different atmega microcontrollers like the 32u4, 328, or 2560?
Thanks.
The Arduino bootloader will be removed when you program the atmega using a programmer.
When you program Arduino using the Arduino bootloader it knows how to write to the image such that the bootloader is preserved.
When you create an image from AVR C and flash it to the atmega the image will overwrite the bootloader, when your atmega is next reset it will now run your image instead of the bootloader.
The process will be the same regardless of the part however your project will need to be set up appropriately.
You can use AVR dude to erase the flash. This thread might help
http://www.avrfreaks.net/forum/how-can-i-erase-chip-using-avrdude
I've managed to run a complicated project on the Nios 2 Altera DE2 board where I created a timer with assembly and C code using the input and output. With the Nios 2 IDE I can download the project to the DE2 FPGA and the clock runs as expected. But I don't understanding everything about the programming model and I'm also trying to understand the basic Hello World example and the diagnostics example that comes with the IDE.
The Hello World example is just
/*
* "Hello World" example.
*
* This example prints 'Hello from Nios II' to the STDOUT stream. It runs on
* the Nios II 'standard', 'full_featured', 'fast', and 'low_cost' example
* designs. It runs with or without the MicroC/OS-II RTOS and requires a STDOUT
* device in your system's hardware.
* The memory footprint of this hosted application is ~69 kbytes by default
* using the standard reference design.
*
* For a reduced footprint version of this template, and an explanation of how
* to reduce the memory footprint for a given application, see the
* "small_hello_world" template.
*
*/
#include <stdio.h>
int main()
{
printf("Hello from Nios II!\n");
return 0;
}
But when I compile and run this "as Nios 2 hardware", it only prints Hello World to the standard out in the IDE, it does not download and run on the board - isn't is supposed to do that? What is the point of the example if it does't run on the board? Did I do anything wrong, if so what since the example compiles and runs? Do I have to set the BSD editor to something?
Update
It's not working at all. I tried the different combinations in the BSP editor and none work. When I try to run the project as "Nios II hardware" nothing happens on the board even though it says in the IDE that the project is downloading to the board. Why is the easy thing difficult? The UX is horrible and having to guess is not scientific.
Here's a link from an Embedded Systems Design Course in Columbia University.
Check the link to lab 3 for an implementation of flashing LEDs with VHDL and C on the Altera DE2 Board.
This implementation uses Altera Quartus, Nios II and the SOPC Builder. I'll try to summarize the steps below:
You would need to write SRAM and LED controllers in VHDL/Verilog to connect to the Avalon Bus. Create a system on the SOPC Builder. Use these controllers to create components in the SOPC Builder (SRAM and LED components).
Connect the components to the Nios II processor, and the JTAG debug module. Assign base addresses and generate your system.
In Nios II, create a C project (Nios II Application and BSP from template) using the SOPC file generated by the SOPC Builder.
Replace the code in the template with a C Program (in this case an LED flasher program). Access the LEDs using the base addresses you generated earlier.
Build and run your program as Nios II Hardware.
More info here.
The program IS running on the board. From the program comments...
This example prints 'Hello from Nios II' to the STDOUT stream.
The STDOUT stream in this case is the software terminal. So the Nios II board is running the hello world program and sending the output to the computer. To use the screen on the board you'll have to include the LCD display in the configuration with the SOPC builder, then write to the LCD screen directly.
From the Nios II documentation (Nios II Software Developer’s Handbook), you have to update your BSP to set stdout as the correct device.
Example:
nios2-bsp hal my_bsp --default_stdio uart1
Probably you didn't understood the flow about how its working, basically
You have to include JTAG-UART module to all your NIOS II System. which is a combination of CPU Debugger and UART communication for the system.
Whenever you use pritnf or scanf statements, there is no standard IO in the hardware. so the system will use JTAG- UART peripheral to communicate with IDE.
The same USB cable is used for downloading as well as JTAG UART
Actually the program is downloading in the hardware and using the USB cable connected with the Kit, printing in the console.
if user wish to change it, do it in BSP Editor but with respective IP added in the system.