Dear All,
I am using 16* 16 multiplier in my program.In program I an first accumulating the variables & then multiplying them.I am using this for measurement purpose.
In one single cycle of AC mains(of 20milli seconds) I am taking 80 samples .ie.4096 samples/Second.So I am accumulating & squaring each samples .I am doing this for every 80 samples .But using 16*16 hardware multiplier result gets overflow.So that I want to use 32*32 multiplier.I was using 16*16 hardware multiplier in following way.
union LONG_UNION
{
//unsigned char c[4];
unsigned int i[2];
signed long l;
};
union LONG_UNION MAC_RESULT;
signed int MAC_REG_A,MAC_REG_B;
RESLO = MAC_RESULT.i[0]; //lower 16 bit result of previous multiplication should be stored in RESLO
RESHI = MAC_RESULT.i[1]; //higher 16 bit result of previous multiplication should be stored in RESHI
MACS = MAC_REG_A; //for signed multiplication and accumulate
OP2 = MAC_REG_B;
_nop();
MAC_RESULT.i[0] = RESLO; //Here MAC Accumulator will have the result
MAC_RESULT.i[1] = RESHI;
I am using 16*16 multiplier as shown in above.So the results were perfectly accurate when ac mains cycle have smaller values.But it gets exceeded when ac mains increased.So I want to use 32*32 multiplier.
I can use it in following way.
MPY32L = // Load lower 16 bits of operand 1
MPY32H =; // Load upper 16 bits of operand 1
OP2L = // Load lower 16 bits of operand 2
OP2H = // Load upper 16 bits of operand 1
But in C I can define maximum upto 32 bit variable only.ie.long data type or float data type.So how to define union as define in above to have 64 bit data type.& how to define that.& how to define 64 bit data types???????????
Thanking you ,
Gokul Tile