AMS AS5048 Eval-Kit User Manual - Page 10
Browse online or download pdf User Manual for Motherboard AMS AS5048 Eval-Kit. AMS AS5048 Eval-Kit 12 pages. 14-bit rotary position sensor with digital angle (interface) and pwm output
Also for AMS AS5048 Eval-Kit: Kit Manual (16 pages), Operation Manual (10 pages)
User Manual – AS5048-AB
dat
= SPI_CMD_READ | SPI_REG_CLRERR;
dat |= spiCalcEvenParity(dat)<<15;
spiTransfer((u8*)&dat, sizeof(u16));
}
else
{
agc = agcreg & 0xff
value = dat & (16384 - 31 - 1);
angle = (value * 360) / 16384
(0..359.9°)
magnitude = magreg & (16384 - 31 - 1);
alarmLo = (agcreg >> 10) & 0x1;
alarmHi = (agcreg >> 11) & 0x1;
}
}
/*!
*****************************************************************************
*
Calculate even parity of a 16 bit unsigned integer
*
*
This function is used by the SPI interface to calculate the even parity
*
of the data which will be sent via SPI to the encoder.
*
*
\param[in] value : 16 bit unsigned integer whose parity shall be calculated
*
*
\return : Even parity
*
*****************************************************************************
*/
static
u8 spiCalcEvenParity(ushort value)
{
u8 cnt = 0;
u8 i;
for
(i = 0; i < 16; i++)
{
if
(value & 0x1)
{
cnt++;
}
value >>= 1;
}
return
cnt & 0x1;
}
/*!
*****************************************************************************
*
Calculate even parity of a 16 bit unsigned integer
*
*
This function is used by the SPI interface to calculate the even parity
*
of the data which will be sent via SPI to the encoder.
*
*
\param[in] value : 16 bit unsigned integer whose parity shall be calculated
*
*
\return : Even parity
*
*****************************************************************************
*/
static
u8 spiCalcEvenParity(ushort value)
{
u8 cnt = 0;
u8 i;
for
(i = 0; i < 16; i++)
{
if
(value & 0x1)
{
cnt++;
}
value >>= 1;
}
return
cnt & 0x1;
}
www.ams.com
// AGC value (0..255)
// Angle value (0.. 16384 steps)
Revision 1.2 / 14.01.2014
// Angle value in degree
page 10/12