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 MMT
AppCallBack(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 vModbusMaster
Task( void *pvParameters )
{
uint8t gucTxBuffer[8];
uint8
t ucSlaveID ;
uint8t ucFunctionCode;
uint16
t usStartAddress;
uint16t usRegisterCount;
uint16
t 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
~~~