Part Number: MSP432P4111
Hi all,
In my current project I have the need for a 64bit wide bitmask, and for clarity in the code I use an enumeration to name the bits in the bit mask.
I've looked in the compiler manual (SPNU151J) and section 5.5.1 seems to say 64bit wide enums are allowed and I think language settings are ok (see below)
Problem is that I can't seem to use my 64bit wide enumerated type as a function parameter. Specifically if I have a function along the lines of void fxn(enum bitmask_e, uint32_t num_u32), then num_u32 is clobbered by the top 32bits of bitmask_e. I haven't looked into what happens with function that have different numbers of parameters, but I'm worried the stack might be corrupted for functions with a single parameter.
Interestingly, if I change my function to be void fxn2(uint64_t bitmask_u64, uint32_t num), the problem goes away, so this problem is specific to passing 64 bit enumerations.
Here is an example program to illustrate the issue. I would expect the value printf'ed by both testFxn1 and testFxn2 to be the same, but they are not.
I've run this program on my MSP-EXP432P401R eval board, compiled with TI 18.12.7.LTS compiler, SimpleLink 3.40.0.05, CCS v9.3.0.00012.
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
typedef enum
{
// Don't need to define every bit for this example, just do every 4th bit.
ewmb_a = 0x0000000000000001,
ewmb_b = 0x0000000000000010,
ewmb_c = 0x0000000000000100,
ewmb_d = 0x0000000000001000,
ewmb_e = 0x0000000000010000,
ewmb_f = 0x0000000000100000,
ewmb_g = 0x0000000001000000,
ewmb_h = 0x0000000010000000,
ewmb_i = 0x0000000100000000,
ewmb_j = 0x0000001000000000,
ewmb_k = 0x0000010000000000,
ewmb_l = 0x0000100000000000,
ewmb_m = 0x0001000000000000,
ewmb_n = 0x0010000000000000,
ewmb_o = 0x0100000000000000,
ewmb_p = 0x1000000000000000,
ewmb_max = UINT64_MAX
} enumWithManyBits;
void testFxn1(enumWithManyBits a_et, uint32_t b_u32)
{
printf("TF1 - 0x%.8x\n", b_u32);
}
void testFxn2(uint64_t a_u64, uint32_t b_u32)
{
printf("TF2 - 0x%.8x\n", b_u32);
}
int main(void)
{
/* Stop Watchdog */
MAP_WDT_A_holdTimer();
testFxn1(ewmb_n, 0xabcdef);
testFxn2((uint64_t)ewmb_n, 0xabcdef);
}
Program Output
TF1 - 0x00100000
TF2 - 0x00abcdef