Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Interrupt in uC/OS-II

Altera_Forum
Honored Contributor II
1,125 Views

Hi,  

 

I use OSSemPost in my Interrupt ISR as follow: 

 

volatile int frame_ready_edge_capture; INT8U error_code; static void handle_frame_ready_interrupts(void* context, alt_u32 id) { /* Cast context to dval_edge_capture's type. * It is important to keep this volatile, * to avoid compiler optimization issues. */ volatile int* frame_ready_edge_capture_ptr = (volatile int*) context; /* Store the value in the dval's edge capture register in *context. */ *frame_ready_edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(FRAME_READY_IRQ_PIO_BASE); /* Reset the dval's edge capture register. */ IOWR_ALTERA_AVALON_PIO_EDGE_CAP(FRAME_READY_IRQ_PIO_BASE, 0); /* * Read the PIO to delay ISR exit. This is done to prevent a spurious * interrupt in systems with high processor -> pio latency and fast * interrupts. */ IORD_ALTERA_AVALON_PIO_EDGE_CAP(FRAME_READY_IRQ_PIO_BASE); error_code = OSSemPost(FVSendVideoDataSem); alt_uCOSIIErrorHandler(error_code, 0); FrameDown= 1; IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led0^=1); //IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led0+=1); frame_ready_edge_capture= 0; } 

 

 

and in my Task: 

 

 

void SendVideoTask() { INT16U rgb_tx_buf_cnt= 0; INT16U cntTCPFrame= 0; INT16U cntVideoFrame= 0; INT32U Data_Pixel; INT16U Data_Pixel_16bit; alt_u8 dot, Dot, packet= 0, DotCnt= 0; INT8U error_code, led= 0; alt_u16 x, y; ..... ..... OSSemPend(FVSendVideoDataSem, 0, &error_code); alt_uCOSIIErrorHandler(error_code, 0); for(y= 0; y<RAW; y++) { for(x= 0; x<COL; x++) { Data_Pixel= IORD_MY_RGB2YUV_IP_DATA(MY_RGB2YUV_BASE); // read 24bit RGB value Dot= Data_Pixel; // isolate B Dot= Data_Pixel >> MY_RGB2YUV_IP_DATA_G_OFST; // isolate G Dot= Data_Pixel >> MY_RGB2YUV_IP_DATA_R_OFST; // isolate R Dot= Dot >> 3; // make 5bit for Blue Dot= Dot >> 2; // make 6bit for Green Dot= Dot >> 3; // make 5bit for Red Data_Pixel_16bit= 0; Data_Pixel_16bit |= Dot << 11 | Dot << 5 | Dot; // merge all in 16bit RGB value alt_up_pixel_buffer_dma_draw(pixel_buf_dev, Data_Pixel_16bit, x, y); // draw pixel on VGA for debug } } 

 

 

the LED_PIO works well, but my Interrupt with OSSemPost in the ISR and OSSemPend in my Task dosn't work. 

 

Could someone say me what I mak ewrong??? 

 

 

Thanks. 

 

Antonio
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
110 Views

I watch wrong in the Signal Tap II, my code work good.... 

sorry
Altera_Forum
Honored Contributor II
110 Views

You must write ones, not zeros, in order to clear edge capture and acknowledge the irq. 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(FRAME_READY_IRQ_PIO_BASE, 1); 

Otherwise the irq would continuously retrigger.
Altera_Forum
Honored Contributor II
110 Views

I suggest to disable the interrupt first and re enable it at last with [h=2]alt_irq_enable(IRQ number)[/h] 

This will avoid re-triggering problem and make sure that ISR executed successfully
Reply