Microchip
直播中

冯敏敏

8年用户 173经验值
私信 关注
[问答]

PIN自定义名称的含义是

你好,我感兴趣的是“自定义模块”在“PIN模块”中的意思。根据我在http://MyCHIPPravestDeave:West:GPIOORD中发现的描述,这就像是PIN的另一个给定名称,这将是在编写配置中未覆盖的任何附加代码时使用的名称。这个页面还说,如果EQ为PIN设置了自定义名称,下面的宏应该在Pin管理器中。在生成代码后,我检查了PixMault.h。我可以看到这些宏//GET/SET RC4过程,定义了RC4xSETHEE():{LATCITS.LATC4=1;}(0)定义了RC4SETWORLVER()DO LATCITS.LATC4=0;}(0)定义了RC4x ToGeLe[()的定义:{LaCTBIT.LATC4= ~LATCITS.LATC4;}(0)α定义。cRb4xStudioDigalIdPUTPUTE()DO TrigCalbId.TrISC4=1;}(0)*定义RC4xStudioDigalOutPututer()DO TrccBist.TrISC4=0;}(0)*定义RC4SeToPulCuffle()DO {WPUCITBES.WPUC4=1;}(0)*定义RC4SeReTePULPULL()DO {WPUCPITS.WPUC4= 0;}(0)RC4GETValuy()端口请让我知道,我是否误解了自定义名称的含义,或者只是做错了什么?MPALBX IDE:4.15xC8:1.45谢谢您的帮助,/ Robi

以上来自于百度翻译


      以下为原文

    hello,
I was interested what the "custom name" means in the "Pin Module". According to the description I found in http://microchipdeveloper...ress:gpiointroduction, this is like a additional given name for the pin, and this will be the name used while writing any additional code not covered in configuration. Also this page says if eq I set the Custom Name for a PIN, the following macros should be in the pin_manager.h:
_SetHigh()
_SetLow()
...
In my project I configured RA4 as digital output, and give the "PWR_STATUS" Custom Name. I checked the pin_manager.h after generated the code, and I can see these macros
// get/set RC4 procedures
#define RC4_SetHigh() do { LATCbits.LATC4 = 1; } while(0)
#define RC4_SetLow() do { LATCbits.LATC4 = 0; } while(0)
#define RC4_Toggle() do { LATCbits.LATC4 = ~LATCbits.LATC4; } while(0)
#define RC4_GetValue() PORTCbits.RC4
#define RC4_SetDigitalInput() do { TRISCbits.TRISC4 = 1; } while(0)
#define RC4_SetDigitalOutput() do { TRISCbits.TRISC4 = 0; } while(0)
#define RC4_SetPullup() do { WPUCbits.WPUC4 = 1; } while(0)
#define RC4_ResetPullup() do { WPUCbits.WPUC4 = 0; } while(0)
Could you please let me know, did I misunderstand the meaning of Custom Name, or just did something wrong?

MPALBX IDE: 4.15
XC8: 1.45

Thanks for your help,
/Robi

回帖(11)

李涛

2018-10-24 17:11:20
定义了RC4xToGeLe[()d{LabcTys.LATC4= LATCITS.LATC4;}(0)可以用:*定义:RC4Twitter TrcBITS.LATC4^=1 / /独占ORC44Twitter;//CAPS,因此您知道它是宏而不是变量或函数。你为什么把它们放进去?

以上来自于百度翻译


      以下为原文

    #define RC4_Toggle() do { LATCbits.LATC4 = ~LATCbits.LATC4; } while(0)
 
You can replace with:
#define RC4_TOGGLE LATCbits.LATC4 ^= 1  //exclusive or
 
RC4_TOGGLE;   //caps so you know that it is a macro rather than a variable or function.
 
Take out all the do..whiles.  Why do you put them in?
举报

吴键洪

2018-10-24 17:16:49
他问为什么“定制的名字”没有被使用。他没有。是MCC把它们放在那里。这是我在别处看到的一些C技巧,以确保宏中的所有语句都被当作一个单独的块。

以上来自于百度翻译


      以下为原文

    He is asking why the "Custom name" is not being used.
 

He didn't. It was MCC that put them there.
This is some C trick I've seen elsewhere to ensure all statements in the macro are treated as a single block.
 
 
举报

李涛

2018-10-24 17:21:53
如果您右键单击RC4YTwitter;或者在代码中的任何地方,选择“导航”,然后单击“查看宏扩展”,您将看到代码将在编译之前查看。

以上来自于百度翻译


      以下为原文

    If you right click RC4_TOGGLE; or anywhere in your code, select, "navigate" and then click, "view macro expansion" you will see the code as it will look before it is compiled.
 
 
举报

李涛

2018-10-24 17:34:22
你会以为用1条单行线是没有理由的。我不使用MCC,认为这是你编写的代码。看起来还行。

以上来自于百度翻译


      以下为原文

    You would have thought that with 1 single line there would be no reason for it.
 
I don't use MCC, thought it was code that you had written.
 
Looks ok.
 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分