Forum Discussion
Hi,
Can you run project in normal mode instead of debug mode?
Try by cleaning project, regenerating bsp, build project and check.
Also try by adding source file directory by clicking run as->run configuration->source->add C:\intelFPGA_lite\18.1\nios2eds\bin\gnu\src ->apply-> run
If possible please do attache the project.
The printf.c file should be available in directory C:\intelFPGA_lite\18.0\nios2eds\bin\gnu\src\newlib-2.2\newlib\libc\stdio
And this function can be accessed by adding header stdio.h.
Regards
Anand
- JKrek7 years ago
New Contributor
Sadly this did not work. It made no change at all.
For the Project Code, it is below, but it is kind of a mess, but any attempt to tidy it up is making the Project not working correctly.
#include "system.h" #include <sys/alt_stdio.h> #include <sys/alt_irq.h> #include <unistd.h> #include "altera_avalon_pio_regs.h" #include "altera_up_avalon_audio.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <limits.h> #include "altera_up_avalon_character_lcd.h" #include "altera_up_avalon_rs232.h" #define SEC 500000 #define BUF_SIZE 792000 // about 10 seconds of buffer (@ 8K samples/sec) #define BUF_THRESHOLD 96 // 75% of 128 word buffer volatile int * green_LED_ptr = (int *) LED_GREEN_PIO_BASE; volatile int* red_LED_ptr = (int*) LED_RED_PIO_BASE; volatile int* switches = (int*) SW_PIO_BASE; volatile int * audio_ptr = (int *) AUDIO_BASE; volatile int * Recording = (int *) RECORD_PIO_BASE; volatile int * PLAY = (int *) PLAY_PIO_BASE; int fifospace; int record = 0, play = 0, transmit = 0, buffer_index = 0, Seg_com = 0; int buffer_nahm = 0, min, max; int temp; char normalized = 0; alt_16 left_buffer[BUF_SIZE],right_buffer[BUF_SIZE]; alt_8 left_normalized[BUF_SIZE], right_normalized[BUF_SIZE]; alt_up_character_lcd_dev * char_lcd_dev; alt_up_rs232_dev* serialport; unsigned int led_val[19]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767, 65535,131071,262143 }; /* function prototypes */ void check_KEYs(int *, int *, int *, int*); void init_vars(); void writeToLCDAt(int xpos, int ypos, char* text); int test(); void normalize(); enum {KEY_0 = 0x0E, KEY_1 = 0x0D, KEY_2 = 0x0B, KEY_3 = 0x07}; int main(int argc, char **argv) { init_vars(); writeToLCDAt(0,0,"Welcome to "); writeToLCDAt(0,1,"L'Audio Recorder"); while (1) { Seg_com = test(); if (Seg_com == 0) { *(green_LED_ptr) = *(green_LED_ptr) | 1; } if (Seg_com == 1) { *(green_LED_ptr) = 0; } check_KEYs(&record, &play, &transmit, &buffer_index); if (record){ *(green_LED_ptr) = 16; // turn on LEDR[0] fifospace = *(audio_ptr + 1); // read the audio port fifospace register max = 0; min = SHRT_MAX; if ((fifospace & 0x000000FF) > BUF_THRESHOLD) {// check RARC // store data until the the audio-in FIFO is empty or the buffer // is full while ((fifospace & 0x000000FF) && (buffer_index < BUF_SIZE)) { *(Recording) = 1; left_buffer[buffer_index] = *(audio_ptr + 2); *red_LED_ptr=led_val[(abs(left_buffer[buffer_index])) *(18) /(SHRT_MAX)]; right_buffer[buffer_index] = *(audio_ptr + 3); ++buffer_index; if(left_buffer[buffer_index] > max){max = left_buffer[buffer_index];}else if(left_buffer[buffer_index] < min){min = left_buffer[buffer_index];} // printf("index: %d name: %d",buffer_index,buffer_nahm); if (buffer_index == BUF_SIZE || (KEY_0 == *((int*) BTN_PIO_BASE))) {// done recording usleep(SEC/2); *(Recording) = 0; record = 0; normalized = 0; *(green_LED_ptr) = 0x0; // turn off LEDR temp = buffer_index; } fifospace = *(audio_ptr + 1); // read the audio port fifospace register } } } else if (play) { *(green_LED_ptr) = 64; // turn on LEDR_1 fifospace = *(audio_ptr + 1); // read the audio port fifospace register if ((fifospace & 0x00FF0000) > BUF_THRESHOLD) // check WSRC { // output data until the buffer is empty or the audio-out FIFO // is full while ((fifospace & 0x00FF0000) && (buffer_index < BUF_SIZE)) { *(PLAY) = 1; *(audio_ptr + 2) =( left_buffer[buffer_index]); if(buffer_index %256 == 0){ *red_LED_ptr=led_val[left_normalized[buffer_index]]; } *(audio_ptr + 3) = (right_buffer[buffer_index]); //alt_up_rs232_write_data(serialport, left_buffer[buffer_index] & 0x00FF); //alt_up_rs232_write_data(serialport, (left_buffer[buffer_index] & 0xFF00) >> 8); ++buffer_index; if (buffer_index == temp || (KEY_0 == *((int*) BTN_PIO_BASE))){// done playback play = 0; *(PLAY) = 0; *(green_LED_ptr) = 0x0; // turn off LEDR } fifospace = *(audio_ptr + 1); // read the audio port fifospace register } } } else if (transmit) { buffer_index = 0; while (buffer_index < 16000 || buffer_index <= temp) { if (alt_up_rs232_get_available_space_in_write_FIFO(serialport) > 2) { alt_up_rs232_write_data(serialport, left_buffer[buffer_index] & 0x00FF); alt_up_rs232_write_data(serialport, (left_buffer[buffer_index] & 0xFF00) >> 8); ++buffer_index; } } transmit = 0; } else if (record == 0 && play == 0 && transmit == 0) { *(PLAY) = 0; *(Recording) = 0; if(normalized == 0) normalize(); *red_LED_ptr = 0x0; writeToLCDAt(0,0,"Standby "); } } } void check_KEYs(int* KEY0, int* KEY1, int* KEY2, int* buffer) { // read the pushbutton KEY values int* BTN_ptr = (int*)BTN_PIO_BASE; if (*(BTN_ptr) == KEY_2) { usleep(SEC); printf("RECORDING START \n"); writeToLCDAt(0,0,"RECORDING "); *buffer = 0; // clear audio-in FIFO *(audio_ptr) = 0x4; *(audio_ptr) = 0x0; *KEY0 = 1; } else if (*(BTN_ptr) == KEY_3) { usleep(SEC); printf("Playback soll abgespielt werden \n"); writeToLCDAt(0,0,"PLAYING "); *buffer = 0; // clear audio-out FIFO *(audio_ptr) = 0x8; *(audio_ptr) = 0x0; *KEY1 = 1; } else if (*(BTN_ptr) == KEY_1 ) { usleep(SEC); writeToLCDAt(0,0,"TRANSMITTING "); printf("Start Transmission!\n"); *buffer = 0; *KEY2 = 1; } } int test() { int Seg_value; volatile int * Seg_ptr = (int *) SEG_COM_BASE; Seg_value = *(Seg_ptr); return Seg_value; } void init_vars(){ *green_LED_ptr = 0x0; *red_LED_ptr =0x0; printf("%d", *switches>>1); char_lcd_dev = alt_up_character_lcd_open_dev(CHARACTER_LCD_NAME); if (char_lcd_dev == NULL){ alt_printf("Error: could not open character LCD device\n"); }else{ alt_printf("Opened character LCD device\n"); alt_up_character_lcd_init(char_lcd_dev); } serialport = alt_up_rs232_open_dev(RS232_UART_NAME); if (serialport == NULL){ alt_printf("Error: could not open serialport device\n"); }else{ alt_printf("Opened serialport device\n"); /*char teststring[] = "Hello World!"; for (int i = 0; i <= strlen(teststring); ++i) { alt_up_rs232_write_data(serialport, teststring[i]); }*/ } printf("Initialisierung fertig !\n"); } void writeToLCDAt(int x_pos, int y_pos, char* text){ alt_up_character_lcd_set_cursor_pos(char_lcd_dev, x_pos, y_pos); alt_up_character_lcd_string(char_lcd_dev,text); } void minmax(int* min, int* max){ *max = *min = left_buffer[0]; for (int i = 1; i < temp;i++ ){ if(left_buffer[i] > *max){ *max = abs(left_buffer[i]); }else if (left_buffer[i] < *min){ *min = abs(left_buffer[i]); } } } void normalize(){ writeToLCDAt(0,0,"Normalizing "); printf("min: %d, max: %d", min, max); for(int i = 0;i<temp;i++ ){ left_normalized[i]=(((abs(left_buffer[i])- min) *(18) /(max - min))); //printf("%d\n",left_normalized[i]); } normalized = 1; }Thank you for your help so far, if you need anything else, let me know.
Jan
- AnandRaj_S_Intel7 years ago
Regular Contributor
Thanks jan,
Can you also attache the .qar file, Click on the Project menu -> Archive Project
- JKrek7 years ago
New Contributor
Here is the link to the .qar file
Sorry for the late reply, I got the notificaion when I was on my way to work.
If you need more Info, let me know.
Thank you for your help so far.
Regards,
Jan
- AnandRaj_S_Intel7 years ago
Regular Contributor
Thanks Jan,
I have used nios2_system.sopcinfo file from project and created a new eclipse project with name testlite and successfully generated elf without any error.
- Delete your software folder and recreate the eclipse project by importing .sopcinfo file.
- or import the software file attached.
Let me know if this has helped resolve the issue you are facing or if you need any further assistance.
Best Regards,
Anand