Forum Discussion
Altera_Forum
Honored Contributor
17 years agoInterruption program
Hello,
I am trying to do an interruption of a video signal. I am using the hsmc quad video card of Bitec associated to a cyclone III C25 Altera card. An interruption is supposed to be generated at each frame. First of all, I don't really understand what is the context, and what I should put in the edge_capture variable. I tried to adapt the interuption program which worked on buttons but no success. It should print "coincoin" whenever an interruption occurs. I put below the parts of my program corresponding to the interruption. Tell me if you need more details. Thanks for helping, Myriam Program : volatile int pouet=0; volatile int edge_capture; static void handle_DMA_interrupts(void* context, alt_u32 id) { volatile int* edge_capture_ptr = (volatile int*) context; if (pouet==0) pouet = 1; } Then in, the main : ... IOWR(video_in_base[0], 0x0, 0x08 ); // enable bit for interrupt IOWR_ALTERA_AVALON_PIO_IRQ_MASK(VIDEO_1_BASE, 0x01); alt_irq_register( VIDEO_1_IRQ,&edge_capture, handle_DMA_interrupts ); while ( 1 == 1 ) { if (pouet == 1) {printf("coincoin"); pouet == 0; } ... }23 Replies
- Altera_Forum
Honored Contributor
No, compiler told you that you need 20832 bytes more (I badly copy the sentence, it is not large, it is larger, sorry). How much memory you have in the SOPC of your design ?
Indeed, your FPGA has 66 M9K blocks, which means 594 kbit or 74 kbyte. To choose which memory use for what, go to the System Library Properties of your project, as I described before. On the right, you can select which memory to use for the program, data, etc. Here select the DDR SDRAM instead of onchip_memory. Jérôme - Altera_Forum
Honored Contributor
It does not work but I need less memory : only 20172 !
Yes but with a Hello-world program, how can it be too large ? Plus, I was wondering about the onchip mem. With a C25 card, I have 0.6MBits of "total memory" (LEs + M9K memory blocks). Does it mean I have 0.6/8=75kBytes of onchip mem ? In this case, I could add more. I am thinking of adding a DDR SDRAM to have more memory, but is it necessarily onchip mem which is missing ? Is there a NIOS command to specify that we want the program to be stored on the DDR SDRAM ? Thanks for answering so quickly, Myriam - Altera_Forum
Honored Contributor
Hi Myriam,
You have a problem with the size of the memory, because the compiler told you "region onchip_mem is full" "Region needs to be 20832 bytes large". Your program is too large for the memory designed. When you regenerate the SOPC file, do you create another project in the Nios II IDE or you still use the same ? If you create another project you should take care about the project properties. In Nios II IDE, when you have created or open your project, click right on the folder corresponding to your project on the "Nios II C/C++ Projects" window, and select "System Library Properties". Check the checkboxs that are enable. if you don't use C++, you can disable "Support C++" , and enable "Program never exits" if the program never exits. Like that the program generated is more light. Maybe you can check the properties of the default design to compare. It is the only thing I see that can cause that, because if you change neither the system in SoPC nor the program, the final size of the program should be the same. Jérôme - Altera_Forum
Honored Contributor
Hi Jérôme,
I am glad you ask because I do have a really mysterious error ! Like I told you before, I have a design with a cpu, onchip mem, a ssram, a flash memory interface, a tristate bridge, a jtag,a i2c bus (BITEC module), a vga and 2 video inputs (those are also BITEC modules). It was extracted from an example which worked. Until now, I never changed anything in SoPC. I made a test and generated sopc again without changing anything. Then, I have the following errors in NIOS (without changing my C code either). I have 32KBytes onchip mem with 32 bit wide data. I made another test and implemented an easy "Hello world" which does not work either ! Do you have an idea where it may come from ? I am really lost there ! Myriam Here is what is written in NIOS II : make -s all includes Compiling main4.c... Linking hsmc_quad_video_mosaic.elf... /cygdrive/c/altera/90/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/bin/ld: region onchip_mem is full (hsmc_quad_video_mosaic.elf section .text). Region needs to be 20832 bytes larger. /cygdrive/c/altera/90/nios2eds/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.6/../../../../nios2-elf/bin/ld: address 0x1fd54 of hsmc_quad_video_mosaic.elf section .onchip_mem is not within region onchip_mem collect2: ld returned 1 exit status make: *** [hsmc_quad_video_mosaic.elf] Error 1 Build completed in 6.828 seconds - Altera_Forum
Honored Contributor
Hi,
Ok, so your design work as you want, or you still have problem or mysterious things to clarify ? Otherwise, I'm glad to have help you. Jérôme - Altera_Forum
Honored Contributor
Hi Jérôme,
Thanks for the "equal error" ! I managed to have my design work. As my interruption was not on a PIO, I got confused. Actually, I did not need masks for my interruption so I removed this line and my design worked ! Once more, thank you for your help. Myriam - Altera_Forum
Honored Contributor
Hello,
Sorry but I am not sure of what you say (I have to improve my english). If you don't have interruption the video works. And if you enable it, it does not work. Is that correct, or it never works ? If it never works, I have no idea because I never works with this design. So what I recommend is to use the default design provide by BITEC, check that it works, and modify it little by little until you have what you want. If it is the interruption that cause problem, like that I don't see where that can coming from. Maybe if you can give details of the different steps of your program please. Else, I missed it before, but you should change the following (I don't know the effect that can have)
byif (pouet == 1) {printf("coincoin"); pouet == 0; }
Jérômeif (pouet == 1) {printf("coincoin"); pouet = 0; } - Altera_Forum
Honored Contributor
Hello,
I don't manage to add buttons and led to my design. Indeed, I based my design on an example given by BITEC on their website. I changed .v files but never changed SoPC files. When I regenerate SOPC without changing anything, the design does not work anymore. I have then a time limited .sof so maybe I am missing some licenses (?) and some files are not correctly regenerated (?). Therefore, I can't touch to SoPC. However, I used your piece of advice and noticed first that like you said, I did not acknoledge the interruption which I did (it is not a PIO port but I found the way to do it). Second, my interruption signal was not generated. Now, it prints "coincoin" :) (see my first post). This means it goes to the ISR. The problem is that whether or not I generate an irq, the video (that is to say the rest of my program) does not work anymore. At least, when there is no irq generated, the rest of the program (which is the while (1)) should work, right ? Do I have to disable/enable something ? Do you have an idea where it may come from ? Your help is very precious ! Myriam - Altera_Forum
Honored Contributor
Hi,
About the context forget it for the moment. It is not compulsory to use it. For example you can register the ISR like that.
And in the ISR function, you do not use the variable context. But it is not the problem, so forget it for the moment. So if I understand well, the interrupt is active when you have activity on the LSB of your video port. What is the name of this signal on your design ? To be sure if you have an interruption and the program goes to the ISR, you can switch on a LED in the ISR. Like that you know rapidly if the problem is here or not. After, as it is a the video port is a PIO port, like in your design with the buttons, the principle is the same. In the ISR, you have to write on the edgecapture register for PIO port (IOWR_ALTERA_AVALON_PIO_EDGE_CAP(VIDEO_1_BASE, 0xFF)). Jérômealt_irq_register( BUTTON_PIO_IRQ, 0, handle_button_interrupts ); - Altera_Forum
Honored Contributor
Hi Jerôme,
I attached two pictures of my top level entity. I am thus trying to interrupt video1. Thanks for your explanation of the context. The problem is that I don't see the context here... The interruption is automatically generated at the end of each frame and I see nothing in the registers which could register the context. Myriam