infineon4engi@twitter infineon@linkedin infineon4engineers infineon@youtube
twitter Facebook Linkedin Youtube

Banner_AURIX_Security-Solution Banner_AURIX_Safety_Products ShieldBuddy TC275 Banner_AURIX_OnzerOS Banner_AURIX_DevelopmentStudio

+ Reply to Thread
Results 1 to 2 of 2

Thread: Doubts on _mfcr command - reg

  1. #1
    New Member New Member Naveen kumar is on a distinguished road
    Join Date
    May 2019

    Doubts on _mfcr command - reg

    We are using Infineon TC-297 Development kit. I am going through the sample code . I got stuck with this part of code. What is the use of the function _mfcr(CPU_CORE_ID) ??? ( where core ID value is 0xFE1C)

    static __inline__ __attribute__((__always_inline__))
    unsigned _mfcr (const unsigned __regaddr)
    unsigned __res;
    __asm__ volatile ("mfcr %0, LO:%1"
    : "=d" (__res) : "i" (__regaddr) : "memory");
    return __res;

    What does this part of code means???

  2. #2
    Intermediate Intermediate HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017

    Hi Naveen,

    What does this part of code means?
    What this snippet accomplishes is that it returns the core identification number of the currently executing core. You need this in a multi-core environment to decide which core is executing and then follow its dedicated code path. As an example, suppose all cores call main after processing the startup code. Then main becomes responsible for distributing the code:

    /* main() called by all cores */
    int main(void) {
      int n = _mfcr(CPU_CORE_ID);
      switch (n) {
        case 0: do_tc0(); break; /* handled by tc0 */
        case 1: do_tc1(); break; /* handled by tc1 */
        case 2: do_tc2(); break; /* handled by tc2 */
      } while (1);
      return 0;
    NB: Note that in terms of main I'm using a different approach than the iLLD sample cases. These do not have a regular main(). Instead its startup code does the core ID check and then immediately routes to core<id>_main.

    Best regards,

    Henk-Piet Glas
    Principal Technical Specialist
    Embedded Systems

+ Reply to Thread

Tags for this Thread


All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.

Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.