Problems with Building a Demo for TriCore

train wrote on Tuesday, June 25, 2019:

Following the Tricore guide,
http://www.freertos.org/FreeRTOS-for-Infineon-TriCore-TC1782-using-HighTec-GCC.html
I get the following error on HighTec IDE:

../RTOSDemo/FreeRTOS_Source/portable/GCC/TriCore_1782/port.c: In function
'pxPortInitialiseStack':
../RTOSDemo/FreeRTOS_Source/portable/GCC/TriCore_1782/port.c:141:4: error:
stray '$' in program
    _mtcr( $FCX, pulUpperCSA[ 0 ] );
    ^

This error appears on every instance of ‘$’ in the code.

Any ideas on how to fix the issue?

rtel wrote on Tuesday, June 25, 2019:

I suspect this will be due to a change in the tools since the example was created. Can you reference any assembly code that comes with the tools, or the assembler’s manual, to see what the new syntax is? Also, is this just when the mtcr macro is used? If so, maybe the semantics of the macro changed?

train wrote on Wednesday, June 26, 2019:

I believe that not the macro itself is the problem, but the use of $ in regaddr.

The macro is:

static __inline__ __attribute__((__always_inline__))
void _mtcr (const unsigned __regaddr, const unsigned __val)
{
  __asm__ volatile ("mtcr LO:%0, %1"
                    :: "i" (__regaddr), "d" (__val) : "memory");
}

and the problematic call for example is:
_mtcr( $PSW, ulMFCR );

It seems that $PSW is not recognizable…

rtel wrote on Wednesday, June 26, 2019:

What does the assembly manual say about this? It looks like PSW is also
a macro (guessing as it is capitalised) so perhaps that has changed.
You can also check the assembly code that comes with the compiler and
the assembly code generated by the compiler to see how it accesses these
registers. Please report back your findings for others with the same issue.

train wrote on Wednesday, June 26, 2019:

I was trying to find the definition of the $ (like $PSW) symbols, but couldn’t find anything in the compiler code.
I have a feeling that it something that used to be when the example was written, but currently doesn’t exist.

The PSW symbol is defined by the SFR_NOABS macro in the tc1782/cpu.h.
SFR_NOABS (PSW, PSW_t, PSW_ADDR); /* “Program Status Word” */

typedef union { /* 32 bits /
struct {
unsigned int CDC:7; /
= [0…6] = 0x0000007f /
unsigned int CDE:1; /
= [7…7] = 0x00000080 /
unsigned int GW:1; /
= [8…8] = 0x00000100 /
unsigned int IS:1; /
= [9…9] = 0x00000200 /
unsigned int IO:2; /
= [10…11] = 0x00000c00 /
unsigned int PRS:2; /
= [12…13] = 0x00003000 /
unsigned int _bit14:1; /
0 = [14…14] = 0x00004000 /
unsigned int _bit15:1; /
0 = [15…15] = 0x00008000 /
unsigned int _bit16:1; /
0 = [16…16] = 0x00010000 /
unsigned int _bit17:1; /
0 = [17…17] = 0x00020000 /
unsigned int _bit18:1; /
0 = [18…18] = 0x00040000 /
unsigned int _bit19:1; /
0 = [19…19] = 0x00080000 /
unsigned int _bit20:1; /
0 = [20…20] = 0x00100000 /
unsigned int _bit21:1; /
0 = [21…21] = 0x00200000 /
unsigned int _bit22:1; /
0 = [22…22] = 0x00400000 /
unsigned int _bit23:1; /
0 = [23…23] = 0x00800000 /
unsigned int _bit24:1; /
0 = [24…24] = 0x01000000 /
unsigned int _bit25:1; /
0 = [25…25] = 0x02000000 /
unsigned int _bit26:1; /
0 = [26…26] = 0x04000000 /
unsigned int SAV:1; /
= [27…27] = 0x08000000 /
unsigned int AV:1; /
= [28…28] = 0x10000000 /
unsigned int SV:1; /
= [29…29] = 0x20000000 /
unsigned int V:1; /
= [30…30] = 0x40000000 /
unsigned int C:1; /
= [31…31] = 0x80000000 */
} bits;
unsigned long reg;
} attribute((aligned(4))) PSW_t_nonv;

typedef volatile PSW_t_nonv PSW_t;

#define SFR_NOABS(name,type,addr)
asm (".global " #name );
asm (".set " #name “,” _STRINGIFY(addr));
asm (".type " #name “,@object”);
extern type name attribute((section(".sfr")))

The last line defines the external variable with name of type
So to reference the PSW register it is enought to write PSW.reg and not $PSW