- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
some iLLD functions use the "IFXCPU_GLB_ADDR_DSPR" macro which converts an local DSPR address to global DSPR address, for example: IfxCpu_waitEvent (in IfxCpu.c). why this?
Solved! Go to Solution.
- Labels:
-
Aurix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry if I confused you.
The Macro is meant for translation from Local address to Global address. It evaluates if the address is local (0xDXXXXXXX, where X - don't care) if yes it converts the address into a Global address otherwise leave as it is.
In this case, the address of a variable passed through a pointer obviously is a global address so it does nothing.
If in case user intentionally uses Local address in the code then this macro converts it into a Global address as you mentioned:
The sync get the value as below if the Local Address 0xD0001234 is used:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi IvanoBono,
Each Core has a local/private view of its own memory (DSPR & PSPR) and the above Macro is used to convert the local/private address to the global address based on the Core. You may refer to section 5.3.6.1.1 Local and Global Addressing section in the User manual for more details. Hope this answers your question.
Prudhvi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am aware of the functioning of the memory addressing of the tc377 and I understand what this MACRO is for. What I don't understand, is why it was used in the "IfxCpu_waitEvent" function.
if, in this function, local addressing had been used instead of global addressing, wouldn't it have worked?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
It won't work if the Local addressing is used, because each core writes to its own DSPR based on the offset calculated from 0xd0000000. Then the intended memory/variable is not written by other cores.
For ex: if the address of the variable used in the function IfxCpu_waitEvent is 0x70000000 the local address of that variable for CPU0 is 0xd0000000.
If the same local address is used then CPU0 writes to its own DPSR : 0x70000000, CPU1 writes to its own DSPR : 0x60000000 & CPU2 writes to its won DSPR : 0x50000000 etc. but not all CPUs write to the memory 0x70000000 where the variable in the function IfxCpu_waitEvent is stored. Here the variable we're discussing about is to be updated by all the cores for Synchronization. Hence this macro is used.
Hope this answers your question.
Prudhvi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't understand the reasoning.
this is the "IfxCpu_waitEvent" function:
boolean IfxCpu_waitEvent(IfxCpu_syncEvent *event, uint32 timeoutMilliSec)
{
volatile uint32 *sync = (volatile uint32 *)IFXCPU_GLB_ADDR_DSPR(__mfcr(CPU_CORE_ID), event);
boolean errorcnt = 0U;
/* Divide with 1000, gives the count value equivalent to milliseconds */
uint32 stmCount = (uint32)((IfxScuCcu_getStmFrequency() / 1000) * timeoutMilliSec);
uint32 stmCountBegin = STM0_TIM0.U;
while ((*sync & IFXCPU_CFG_ALLCORE_DONE) != IFXCPU_CFG_ALLCORE_DONE)
{
__nop();
if ((uint32)(STM0_TIM0.U - stmCountBegin) >= stmCount)
{
errorcnt = 1;
break;
}
/* There is no need to check overflow of the STM timer.
* When counter after overflow subtracted with counter before overflow,
* the subtraction result will be as expected, as long as both are unsigned 32 bits
* eg: stmCountBegin= 0xFFFFFFFE (before overflow)
* stmCountNow = 0x00000002 (before overflow)
* diff= stmCountNow - stmCountBegin = 4 as expected.*/
}
return errorcnt;
}
"__mfcr(CPU_CORE_ID)" returns the id of the current core.
so if I call:
IfxCpu_waitEvent(0xD00001234,timeout);
sync get the value:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry if I confused you.
The Macro is meant for translation from Local address to Global address. It evaluates if the address is local (0xDXXXXXXX, where X - don't care) if yes it converts the address into a Global address otherwise leave as it is.
In this case, the address of a variable passed through a pointer obviously is a global address so it does nothing.
If in case user intentionally uses Local address in the code then this macro converts it into a Global address as you mentioned:
The sync get the value as below if the Local Address 0xD0001234 is used:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't imagine a situation where someone has to use this function with local address (0xDxxxxxxx). cmq I would say that we can close the question.