Page 1 of 1

Register Field Union Defs "Backward Compatibility" why?

Posted: 01 Nov 2020 18:47
by steve42lawson
I don't understand why this, that I consider the better solution, is labeled "backward compatibility for...", in the "Defs" files.

Defining the register definitions as Union of Struct, with bit-mapped fields seems to me, the correct [best] way to do it. For instance, my real-life case where I want to temporarily change the Timer 1 Prescale bits. The MikroC "accepted" [apparently] way of doing it is:

Code: Select all

	TCKPS_0_bit = 1; 
	TCKPS_1_bit = 1; 
But, at least to me, a far cleaner, and more standard way of doing it is [and the way I would much rather do it]:

Code: Select all

	T1CONbits.TCKPS = 0x3;
BUT, you scare me, Mikroe, with your language!! Can I rely on this to exist in future Mikroe C compilers?! Or is this, indeed, deprecated?!?

Re: Register Field Union Defs "Backward Compatibility" why?

Posted: 05 Nov 2020 09:47
by filip
Hi,

The first notation was introduced when PRO compilers were released.
The second one is from pre-PRO compilers and was taken from the MPLAB, this is why backward compatibility is mentioned.

This is not deprecated, you can use any notation you wish.

Regards,
Filip.

Re: Register Field Union Defs "Backward Compatibility" why?

Posted: 06 Nov 2020 15:46
by steve42lawson
Cool, thank you.

May I suggest that you add that to the documentation?

Re: Register Field Union Defs "Backward Compatibility" why?

Posted: 09 Nov 2020 15:41
by filip
Hi,

Yes, I will pass this to our documentation writers.

Regards,
Filip.