Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Issue with serial interrupt with FreeRTOS

Posted by savindra on May 13, 2016

Hello,

I am using renesas RX62N platform. My application is as below : I have a task that is running at 50ms and it is sending serial data to a slave device.Slave device is giving response after receiving this serial data. I have setup a interrupt service routine with priority level 5 in renesas platform. My ISR is receving each byte and putting it into RAM buffer when buffer exceed 21 byte then i am giving a semaphore to my task(50 ms task) to use that buffer data.

Apart from i have two more task and two more pheripheral ISR. Please help me to know if i am missing anything to configure pheripheral ISR with FreeRTOS.

My code is running for some seconds and after that it is giving below exception: void Excep_BRK(void){ wait(); }

Below the code:

My ISR : ~~~ void MMTAppCallBack(void) { static signed portBASETYPE xHigherPriorityTaskWoken; /// Declare error flag bool err = true;

/// Configure the SCI receive interrupt
err &=    R_SCI_Receive
          (
          2,
          PDL_NO_DATA,
          &gucRxBuffer,
          1,
          MMT_AppCallBack,
          PDL_NO_DATA
          );

/// Halt in while loop when RPDL errors detecte
while (!err);


xHigherPriorityTaskWoken = pdFALSE;

/// Unblock the task by releasing the semaphore
xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );

/// If xHigherPriorityTaskWoken was set to true you
///we should yield.  The actual macro used here is
///port specific
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

}///end MMT_AppCallBack ~~~

My Task: ~~~ void vModbusMasterTask( void *pvParameters ) { uint8t gucTxBuffer[8]; uint8t ucSlaveID ; uint8t ucFunctionCode; uint16t usStartAddress; uint16t usRegisterCount; uint16t usQueryCrc; uint16t usCrc; uint16_t usResponseCrc;

ucSlaveID = 1;
ucFunctionCode =4;
usStartAddress = 1;
usRegisterCount = 8;

gucTxBuffer[0] = ucSlaveID;
gucTxBuffer[1] = ucFunctionCode;
gucTxBuffer[2] = ((usStartAddress >> 8) & 0xFF);
gucTxBuffer[3] = ((usStartAddress ) & 0xFF);
gucTxBuffer[4] = ((usRegisterCount >> 8) & 0xFF);
gucTxBuffer[5] = ((usRegisterCount ) & 0xFF);

( void ) pvParameters;
portTickType xNextWakeTime;
/// Initialise xNextWakeTime - this only needs to be done once
xNextWakeTime = xTaskGetTickCount();
///intialise modbus master
MMT_Init();

/// We are using the semaphore for synchronisation so we create a binary
///semaphore rather than a mutex.  We must make sure that the interrupt
///does not attempt to use the semaphore before it is created.
xSemaphore = xSemaphoreCreateBinary();


for( ;; )
{

	/// Place this task in the blocked state until it is time to run again 
	///The block state is specified in ticks, the constant used converts ticks to ms
	vTaskDelayUntil( &xNextWakeTime, configMODBUS_MASTER_FREQUENCY_50MS );

	usQueryCrc = MMT_CRC16(gucTxBuffer,6);

	gucTxBuffer[6] = (usQueryCrc & 0xFF);
	gucTxBuffer[7] = ((usQueryCrc >> 8)&0xFF);

    /// Send modbus rtu query
    R_SCI_Send
             (
             2,
             PDL_NO_DATA,
             gucTxBuffer,
             8,
             PDL_NO_FUNC
			 );


   ///  Block waiting for the semaphore to become available
    if( xSemaphoreTake( xSemaphore, 1 / portTICK_RATE_MS ) == pdTRUE )
    {
	///do this work				  			
	}


        /// We have finished our task.  Return to the top of the loop where
        ///we will block on the semaphore until it is time to execute
        ///again.  Note when using the semaphore for synchronisation with an
        ///ISR in this manner there is no need to 'give' the semaphore back.
    }	 

}

}///end vModbusMaster_Task ~~~


Issue with serial interrupt with FreeRTOS

Posted by rtel on May 13, 2016

We can't comment on chip specifics (reading and writing to the UART), only on the use of FreeRTOS.

The first thing you need to determine is how you are getting into the Excep_BRK(void){ wait(); } statement. Is this a fault exception handler, or an unpopulated interrupt handler.

Which compiler are you using? Have you followed the guidelines on the documentation page (on the FreeRTOS.org website) for your port with regards to writing interrupt service routines?

Have you ensured the priority of the ISR is at or below the configMAXSYSCALLINTERRUPT_PRIORITY setting?


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS