- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Support/Expert
I have a very simple code while I play with Nois2 and SPI interface.
/* "Hello World" example.
*/
#include "alt_types.h"
#include "altera_avalon_spi_regs.h"
#include "altera_avalon_spi.h"
#include "system.h"
#include <stdio.h>
#include <unistd.h> // usleep
int main( void){
printf ("Entered Main \n");
alt_u8 send_M;
alt_u8 count;
count = 0;
while (1) {
send_M = count;
IOWR_ALTERA_AVALON_SPI_TXDATA(SPI_0_BASE, send_M);
// Wait for transfer to complete
usleep(75);
// Print results
printf("master sent = %d \n",send_M);
count ++;
usleep(1000000);
} // end while
return 0;
}
--------------------------------
I will have this compile error
Description Resource Path Location Type
make: *** [spi_test2.elf] Error 1 spi_test2 C/C++ Problem
recipe for target 'spi_test2.elf' failed Makefile /spi_test2 line 1015 C/C++ Problem
I have tried %i, %c, %u. none of them can pass project build.
but if I comment off the
printf("master sent = %d \n",send_M);
the project will build successfully.
I am new to Nios and eclipse, and I don't write C code.
what is the problem of this printf sentence and how to solve it?
Thank you,
David
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For printf, you may try the uart core for data read write.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Eric
I don't fully understand your answer, my test platform can print text only string. if I don't use any % print format. when you say "try uart core" do you mean FPAG core, or eclipse domain.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can add uart in your Platform Designer, which will be located in the FPGA fabric.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Eric
I have Uart core, I can printf the pure test string. but the compiler will report error when I printf with format, for example %c.
do you mean if I add a uart core will solve this problem?
Thank you,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes you are right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I’m glad that your question has been addressed, I now transition this thread to community support. If you have a new question, feel free to open a new thread to get the support from Intel experts. Otherwise, the community users will continue to help you on this thread. Thank you.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page