FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [May 2016 Threads]
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
~~~
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?
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.