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] [April 2014 Threads]
Hi,
I'm setting up a FreeRTOS v8.0.0 application on an STM32L1xxB (Cortex M3) based. I have a strange issue when calling I2C functions within my tasks :
whenever I call a function to write some I2C data it will trigger corresponding interrupts only if :
1) it gets called in the task initializazion section (before the inifinite for loop)
AND
2)It gets wrapped in a function itself.
For example, my I2C function is I2CWriteReg(DeviceAddress, RegAddress, numdata, &beffer[0]);
Related TX interrupts will be generated only I do the following :
uint32t I2CInitializeRegister(...)
{
return I2CWriteReg(DeviceAddress, RegAddress, num_data, &beffer[0]);
}
and then I call the function from the task inititlization section :
static void LedTask( void pvParameters )
{
I2CInitializeRegister(...);
/ if I call I2C_WriteReg(...) here it will not work */
for(;;){
/* if I call I2C_WriteReg(...) here it will not work */
}
}
Same thing holds for I2C RX interrupts when I use I2C_ReadReg(...)
I've taken precautions on NVICPriorityGroup = 4 and tested the I2C interrupts with priority 0 (maximum) and then 12 that is between configLIBRARYMAXSYSCALLINTERRUPTPRIORITY (=5) and configLIBRARYLOWESTINTERRUPT_PRIORITY(=15) since in later developments I'm planning to use xSemaphoreGiveFromISR(...) functions within I2C interrupt context to wake up tasks waiting for I2C operations.
Do you have any suggestion on what my problem might be related to ?
Best Regards,
Adalberto
If I understand your post correctly it would seem rather bizarre, which of course it can't really be, there must be some logical explanation. If I understand you correctly then calling:
ReturnedValue = I2C_WriteReg(Device_Address, Reg_Address, num_data, &beffer[0]);
... does not result in the expected value in the ReturnedValue variable, but calling
uint32_t AnOtherFunction( void )
{
return I2C_WriteReg(Device_Address, Reg_Address, num_data, &beffer[0]);
}
ReturnedValue = AnOtherFunction();
does result in the expected value in the ReturnedValue variable.
What is the expected value, and why do you say the first case is not working? Can you step through the assembly code in each case to see what the differences are? The value returned from the function should be returned in R0 (the register R0).
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.