Device Version and Compatibility Testing
========================================
This procedure is to be used for verifying a part for software compatibility 
and version identification. The procedure can be used both externally by 
reading through SWD or by on-board software by reading memory mapped 
locations. The physical addressing of the data location depends on which of 
these methods are chosen but yields the same data. When ``DEVICEID`` is read use 
``SYS0:DEVICEID`` when running on-board software or ``CFGAP:DEVICEID`` over SWD.
When ``PARTID`` is read, use ``SYS0:PARTID`` when running on-board software or 
``CFGAP:PARTID`` over SWD. 

All fields shall be parsed as unsigned binary coded integers.

To use SWD please refer to the |DEVICE| techincal reference manual.

Reading ``SYS0`` Register CCS
-----------------------------
Code Composer Studio provides an interface to read registers from |DEVICE|. 

1. Start a debug session with the |DEVICE|.
2. Click on ``View`` |rarr| ``Registers``.

Reading ``SYS0`` Register ``HWREG()`` Macro
-------------------------------------------
``HWREG()`` may be used to read internal registers using their base 
addresses. Base addresses for various registers may be found in the |DEVICE|
technical reference manual. If using this macro, please be aware of any 
limitations to the address accessed i.e. if it supports word and/or byte access.

.. code-block:: c
    :caption: HWREG() Example
    :linenos:

    // Read example
    my32BitVar = HWREG(base_addr + offset) ;
    
    // Write example
    HWREG(base_addr + offset) = my32BitVar ;

The base address for the ``SYS0`` register is ``0x40004000``. The offset for 
``DEVICEID`` is ``0x3FC`` and ``PARTID`` is ``0x7F8``. Please see the |DEVICE| 
technical reference manual for more information.

Process
-------
First, establish that the device is a |DEVICE| family device by reading the 
manufacturer identifier. If running on-board software, this is assumed to be
given. If this does not match, this document does not apply to the device. 

Read ``DEVICEID.DEVICE``, ``DEVICEID.MANUFACTURER`` and ``DEVICEID.ALWAYSONE`` 
and verify this value is identical to the expected value. Ignore 
``DEVICEID.VERSION`` as this value can change without changing compatibility. 
If it does not match, stop.

If ``DEVICEID`` matches then check ``PARTID`` as follows:

1. Check that ``PARTID.PART`` is exactly the expected value. 
    If this is different the part is a different device in the same family and 
    code must be checked and potentially re-verified.

2. Check that ``PARTID.VARIANT`` is exactly as expected. 
    If this is different this is a memory or package variant of the same device 
    and code must be checked for compatibility with this variant.

3. Check that ``PARTID.MAJORREV`` is exactly as expected. 
    If this value is less than expected the device is older and may have reduced
    functionality. If it is higher it may have changes that break existing 
    software compatibility and errata information should be checked and software 
    should be re-verified for the new revision.

4. Check that ``PARTID.MINORREV`` is greater than or equal to the expected 
    value. No action is needed as any changes on the device is assured from the 
    manufacturer to be compatible. If it is less than the expected value there 
    may be added workarounds or features missing that may cause compatibility 
    issues so errata notes and version update notes should be checked and 
    software should be re-verified.