Topoestivo,
In the Accelerometer example, the function doAccelMeasurement() reads the XYZ measurements. The macros to setup these channels appear in MC13213XSRB.h.Please look in that file.
- Within the definition of ACCEL_INIT_MACRO, 'ATD1C=0xE1' sets the ATD result to return an 8-bit unsigned result instead of a 10-bit result. Thus, the result is read from ATD1RH.
- 'ATD1PE=0x1C' declares the analog pins are connected to bits 2, 3, and 4 of Port B.
- 'ATD1SC=2' initiates the A/D conversion on the analog channel connected to bit 2.
- After initiating A/D conversion, continuously read ATD1SC until the Conversion Complete Flag is set which indicates that ATD1RH contains the result.
The offsets that doAccelMeasurement() uses are determined by the particular hardware that is the source of the analog signal and whether you wish to shift the value to a different result band for some reason.
Regards,
Chuck