怎样读写PSoC4的寄存器?

[复制链接]
1301|2
 楼主| zhaoruzhe 发表于 2017-2-7 11:00 | 显示全部楼层 |阅读模式
本帖最后由 zhaoruzhe 于 2017-2-7 12:22 编辑

读写PSoC的寄存器,主要是使用:CY_GET_REG32(uint32 Register_Address)
CY_SET_REG32(uint32 Register_Address, uint32 Data)
用例如下,可以使用Debug查看CapSense_Start()、CapSense_Stop()前后,CSD模块的相关寄存器值变化。
在一些特殊的应用、调试的场合,直接对寄存器操作也有重要作用。

PSoC的寄存器详细介绍主要在各个PSoC产品的TRM里面,例如PSoC4000的Register TRM:
http://www.cypress.com/documenta ... technical-reference

  1. #include <project.h>

  2. uint32 CapSense_Registers[4]={0x40080000,0x40080004,0x40080008,0x4008000C};
  3. uint32 CapSense_Registers_GetI[4]={};
  4. uint32 CapSense_Registers_GetII[4]={};
  5. uint32 CapSense_Registers_GetIII[4]={};

  6. int main()
  7. {   
  8.         /* Enable Global interrupts */
  9.     CyGlobalIntEnable;
  10.         CyDelay(20);
  11.    
  12.     uint8 status_i;
  13.    
  14.     for(;;)
  15.     {
  16.         for(status_i=0u;status_i<4u;status_i++)
  17.         {
  18.             CapSense_Registers_GetI[status_i] = CY_GET_REG32(CapSense_Registers[status_i]);
  19.         }
  20.         ;
  21.         CapSense_Start();
  22.         CyDelay(200);
  23.         ;
  24.         for(status_i=0u;status_i<4u;status_i++)
  25.         {
  26.             CapSense_Registers_GetII[status_i] = CY_GET_REG32(CapSense_Registers[status_i]);
  27.         }
  28.         ;
  29.         CapSense_Stop();
  30.         CyDelay(200);
  31.         ;
  32.         for(status_i=0u;status_i<4u;status_i++)
  33.         {
  34.             CapSense_Registers_GetIII[status_i] = CY_GET_REG32(CapSense_Registers[status_i]);
  35.         }
  36.         ;
  37.     }
  38. }



leijixiaomile 发表于 2017-2-7 21:03 | 显示全部楼层
 楼主| zhaoruzhe 发表于 2017-2-8 10:25 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:小搬运工

26

主题

289

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部