I solved the problem, it was something about setting priority level in NVIC(nested vector interrupt controller) more than 7.
So I made 2 additional functions to set_irq_priority and to do enable_irq.
void enable_irq (int irq){ int div; /* Make sure that the IRQ is an allowable number. Right now up to 91 is * used. */ if (irq > 91) printf("\nERR! Invalid IRQ value passed to enable irq function!\n"); /* Determine which of the NVICISERs corresponds to the irq */ div = irq/32; switch (div) { case 0x0: NVICICPR0 = 1 << (irq%32); NVICISER0 = 1 << (irq%32); break; case 0x1: NVICICPR1 = 1 << (irq%32); NVICISER1 = 1 << (irq%32); break; case 0x2: NVICICPR2 = 1 << (irq%32); NVICISER2 = 1 << (irq%32); break; } } And the one to set priority:
void set_irq_priority (int irq, int prio){ /*irq priority pointer*/ uint_8 *prio_reg; /* Make sure that the IRQ is an allowable number. Right now up to 91 is * used. */ if (irq > 91) printf("\nERR! Invalid IRQ value passed to priority irq function!\n"); if (prio > 15) printf("\nERR! Invalid priority value passed to priority irq function!\n"); /* Determine which of the NVICIPx corresponds to the irq */ prio_reg = (uint_8 *)(((uint_32)&NVICIP0) + irq); /* Assign priority to IRQ */ *prio_reg = ( (prio&0xF) << (8 - ARM_INTERRUPT_LEVEL_BITS) ); } So now all my interrupts are working how I want them to work !!
But another problem came to my attention when I use the DMA transfer on circular queue and the Destination modulo 2 address incremented with offset 1 byte. To transfer data from UART5 Data register, if the start address of the buffer variable is not aligned to a modulo 2 address. It's going to cut from your space available for buffer elements.
Exemple
If i have a modulo 2 bits for incrementing the destination address and the start address for buffer is 0xfffff350
I have 0xfffff350 first element
0xfffff351 second one
0xfffff352 3th
0xfffff353 4th one
and if the compiler allocates the start address for the buffer the address 0xfffff352
I remain only with 2 available locations for my buffer to store my data's because the modulo 2 feature let me to increment only the last 2 bits from the start address of the buffer.
So my question is how can I determine the compiler to allocate in memory my buffer to start at the right address.
This is the code for DMA configuration
/********************************************************************//* * Configuration of DMA_channel and start of the movement data from * UART5 Data register address and to a queue(circular stack) with the * beginning address of the buffer variable as a destination address. * The destination address will be incremented with the width of the transfered * data in bytes from the source address in this case sizeof the UART5 Data register * */void dma_config_start(uint_8 channel){ DMA_CITER_ELINKNO_REG(DMA_BASE_PTR,channel)=DMA_BITER_ELINKNO_REG(DMA_BASE_PTR,channel)=sizeof(UART5_D); DMA_NBYTES_MLNO_REG(DMA_BASE_PTR,channel)=sizeof(UART5_D); DMA_SOFF_REG(DMA_BASE_PTR,channel) = 1; DMA_SADDR_REG(DMA_BASE_PTR,channel)=(uint_32)&UART5_D; DMA_ATTR_REG(DMA_BASE_PTR,channel)=DMA_ATTR_SMOD(0)|DMA_ATTR_SSIZE(0)|DMA_ATTR_DMOD(2)|DMA_ATTR_DSIZE(0); DMA_SLAST_REG(DMA_BASE_PTR,channel)=-sizeof(UART5_D); DMA_DADDR_REG(DMA_BASE_PTR,channel)=(uint_32)&buffer; DMA_DOFF_REG(DMA_BASE_PTR,channel) = sizeof(UART5_D); DMA_DLAST_SGA_REG(DMA_BASE_PTR,channel) = 0; DMA_SERQ_REG(DMA_BASE_PTR)=DMA_SERQ_SERQ(5); DMA_ERQ_REG(DMA_BASE_PTR) |=(1<<channel); DMA_CR |=DMA_CR_EDBG_MASK; //Enable Debug MODE in DMA //DMA_INT_REG(DMA_BASE_PTR) |=DMA_INT_INT5_MASK; DMA_CSR_REG(DMA_BASE_PTR,channel)=DMA_CSR_INTMAJOR_MASK; //DMA_CSR_START_MASK;}