This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hi,
I have problems accessing the addres of variables which are marked with the byte_peripheral attribute inside a struct.
This part compiles without issues:
typedef unsigned long bp_32 __attribute__((byte_peripheral));
bp_32 var = 1;
bp_32 *varPtr = &var; // points to var
But if I encapsulate the variable in a struct, this does not work anymore:
struct {
uint32_t val1;
bp_32 val2;
} aStruct;
bp_32 *structVal1Ptr = &aStruct.val1; // works fine
bp_32 *structVal2Ptr = &aStruct.val2; // fails
The error message I'm getting in the last line is "Illegal use of intrinsic: __byte_peripheral_32" which is also a bit strange since I'm using the attribute. Guess that the compiler is just doing some kind of search/replace of the attribute.
This is quite in my way as I sometimes want to access the address of some registers which in this case does not work if they are marked with byte_peripheral.
Here is an example which also fails:
volatile bp_32 *perRegPtr = &CanbRegs.CAN_IF3UPD;
I'm using version 22.6.1 LTS from the latest C2000 Ware version 5.02.00.00.
Do you have a tip how I can get this working?
Thanks a lot and best regards,
Oliver
Unfortunately, this ...
accessing the addres of variables which are marked with the byte_peripheral attribute inside a struct.
... is not supported.
To get a better idea of how byte peripheral access is typically used, I suggest you view the examples in C2000Ware which use it. I am not familiar with C2000Ware, so I will notify the C2000Ware experts about this thread.
Thanks and regards,
-George
Hi,
You can refer to the drivers provided within C2000Ware for the byte peripherals like LIN.
The macro HWREG_BP is used to write to such registers.
Best Regards
Siddharth
Thanks for the fast response and the different alternatives.
Yes, one option is to use the HWREG_BP to access registers:
HWREG_BP(CANB_BASE + CAN_O_IF3UPD);
But this is not really what I need. What I want is a pointer, in this case, to CANB_BASE + CAN_O_IF3UPD, which is just a number, so this is identical with:
bp_32 *ptr = (bp_32 *)(CANB_BASE + CAN_O_IF3UPD); // works
bp_32 *ptr = (bp_32 *)0x4A160; // works too
But repeating CANB_BASE + CAN_O_IF3UPD is painful, clutters the code and adds more dependencies when the struct already knows the address.
Another workaround is to add another layer to the struct:
struct {
union { bp_32 val2; } un2;
} aStruct;
bp_32 *structVal2Ptr = (bp_32 *)&aStruct.un2; // works
But again, this is not nice, as I have to modify the TI structs/headers for this and it makes the code harder to read.
... is not supported.
Is it maybe possible that you forward this request to the compiler team?
Perhaps it is just a small change in the compiler and it would make the usage of this register struct more efficient and easy.
Thanks a lot and best regards,
Oliver
I filed a request for this feature to be added to the compiler. Unfortunately, there is a problem with the part of the system that makes such requests visible to customers. So I am unable to give you a link. The internal ID for the request is CODEGEN-12564.
Please do not think that filing the request means it gets implemented. It has to be approved, scheduled, etc.
Thanks and regards,
-George
Unfortunately, there is a problem with the part of the system that makes such requests visible to customers.
Unfortunately, this problem has not been resolved. I remain unable to get you a link.
Thanks and regards,
-George
The entry EXT_EP-11796 has been filed. You are welcome to follow it with that link. Thank you for your patience.
Thanks and regards,
-George
The internal ID for the request is CODEGEN-12564.
Please do not think that filing the request means it gets implemented. It has to be approved, scheduled, etc.
Understood and thanks a lot!
Best regards,
Oliver