Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem in excuting RX internal interrupts with a task under freertos

Status
Not open for further replies.

sabra88

Newbie level 2
Joined
Aug 1, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
121
Hello everybody,
I have interfaced a master board with a slave board and i am sending a buffer from the master and reading it on the slave using RX interrupt handler (internal interrupts) to pass the data from SPI to the task.
The problem is that the interrupt is excuted only one time and then it is blocked but i need to excute the interrupt as many times as the received characters and after receiving the whole packet, i send it into a queue to the task.
I work under EFM32 mcu.
What am I missing??


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**************************************************************************//**
 *  USART2 RX IRQ Handler
*****************************************************************************/
void USART2_RX_IRQHandler(void)
{
  USART_IntClear(USART2, USART_IF_RXFULL);
 
  if (USART2->STATUS & USART_STATUS_RXFULL)
  {
      /* Reading out data */
      rxdata = USART2->RXDOUBLE;
 
    if (slaveRxBufferIndex < slaveRxBufferSize)
    {
      /* Store Data */
      slaveRxBuffer[slaveRxBufferIndex] = rxdata;
      slaveRxBufferIndex++;
    }
  }
  if(slaveRxBufferIndex == slaveRxBufferSize)
  {
      slaveRxBufferIndex=0;
      receive_irq_handler();
  }
}
 
/**************************************************************************//**
 *  software interrupt which sends data to the queue after receiving the whole packet
*****************************************************************************/
void receive_irq_handler(void)
{
    portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
 
    T_Concentrator_CMD.FromModule = Module_IRQ;
    T_Concentrator_CMD.ID_Service = slaveRxBuffer[0]>>8; //take the most significant bits of the first word
    T_Concentrator_CMD.ID_trame = slaveRxBuffer[0];
    T_Concentrator_CMD.Nb_Data = slaveRxBuffer[1]>>8;
    T_Concentrator_CMD.ID_Device = slaveRxBuffer[1];
 
    data_length = (T_Concentrator_CMD.Nb_Data)*2;
    memcpy(T_Concentrator_CMD.Payload,slaveRxBuffer+0x02 ,data_length);
 
    status=xQueueSendFromISR(xQueueConcentratorTask, &T_Concentrator_CMD,0 );
 
    if(status == pdPASS)
    {
        #ifdef DEBUG_FREE_RTOS
         vPrintf( "ISR successfully send data to Concentrator task\n" );
        #endif
    }
    else
    {
       #ifdef DEBUG_FREE_RTOS
       vPrintf(" Request Could not be sent to xQueueConcentratorTask\n" );
       #endif
    }
    portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}

 
Last edited by a moderator:

I noticed this thread because it mentioned FreeRTOS, but from the sound of it your problem is related to using the UART interrupt rather than FreeRTOS. There is one thing I would like to point out in your use of the xQueueSendFromISR() function though. Although you define the xHigherPriorityTaskWoken variable and correctly initialise it to pdFALSE, you don't actually use it, but instead pass in 0 as the function's last parameter. If you were to pass in &xHigherPriorityTaskWoken it would ensure the interrupt returned directly to the woken task, if it is now the highest priority task. The code you have is still valid, but the switch won't occur until the currently running task blocks or yields, or at the very latest, when the next tick interrupt occurs.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top