Accessing PSoC 3/5 Registers in Firmware

Version 1
    Question: How do I access (Read/Write) the Registers of PSoC 3/5 in firmware?

     

    Answer:

    To access registers in firmware, use the following functions.

    CY_SET_REG8(addr, value);

    CY_GET_REG8(addr);

     

    Similarly REG16 & REG32 functions are also there. Please refer to System Referecne Guide for more APIs.


    Example:

    CY_SET_REG8(CYDEV_IO_PRT_PRT1_DR, 0X01)); // Write the value 1 to Port 1 Data Register.

    Port1Register = CY_GET_REG8(CYDEV_IO_PRT_PRT1_DR);  // Read the Port 1 Data Register into a Variable "Port1Register"


    The macro is defined in the header file, cytypes.h".  PSoC 3/5 registers are defined in the header file "cydevice.h"