卡兰,我必须检查图腾概述的方法,因为我模糊地记得读过它。至于我所做的,我通常采用迭代的方法来创建一个BSP。你应该做的第一件事是找出BS/CONFIG中的哪些DS文件对应于你的处理器。您将在这里找到一个HCONFIG文件的列表:C:Microchip HealthV2Y03B实用工具MHCCONFIG。只要找到你的处理器,打开它,DS文件的名字就会排在前10行左右。你最终会把你的BSP信息添加到那个文件中,这样它就会出现。需要注意的两件事是:让您的自定义板默认位于DSXXXX文件的顶部,您可能需要在该文件的底部添加一些逻辑来覆盖一些常见的特性。至于BSP本身,复制一个您认为类似于您的项目。BSP.HCONFIG是您将花费大部分时间进行黑客攻击的文件。然而,在你做任何事情之前,你需要重新命名一些东西。我建议使用TeTPad或类似的东西来查找和替换所有的东西,而不是自己动手。假设您已经启动了一个项目,请查看生成的MHC文件。你会发现很多东西可以在你的BSP中重复使用。我不仅增加了PIN的名称,而且还增加了PPS设置、方向、PULUPS、驱动程序选择/设置、堆栈选择等。从一个大的角度来看,我将启动一个项目,启用计时器服务,并使用SysStMRMyDelayMS和SysStTMR.DelayStaseGET函数来创建延迟,以便我可以tog。拨弄一个别针在示波器上看,如果切换频率匹配,那么我马上就知道一些事情。我知道我的时钟设置是有序的,可能是我的配置位,当然是计时器系统服务。然后我可以从MHC文件中偷走这些设置并把它们放入BSP中。这意味着我可能不再需要重新访问配置位。从这里开始,我将向项目中添加一些东西并逐一测试。当一些东西工作时,我会回去把它添加到BSP文件中。为了确保BSP做它应该做的事情,我会重新启动MHC,而不在提示时选择一个配置文件。然后我将检查BSP,因为我的BSP是前面所说的默认值,如果我做的正确的话,我想要的所有设置都将被填入。在你的情况下,我不能真正强调这个缓慢而迭代的方法来完成一个项目。几乎每一次我开始一个新的项目而不做这件事,我就陷入困境,并开始假设事情是真的不是这样。由于图形堆栈非常复杂,您需要消除所有的疑虑。你已经很好地选择了一个支持的图形处理器,希望你已经把硬件从一些微芯片演示板复制到了字母。这样,当事情不一定解决的时候,你可以消除硬件。图腾指出的方法和和谐文献的大纲,可能比我所写的要好得多。但是,你会对BSP有一个很好的理解,这对你将来会有帮助。有一个坚实的BSP为你的项目,无论你是如何获得它是远远优于从零开始每一个项目。最后,不要让免费的模板语言吓唬你。在Microchip前面有明确的文档,在大多数情况下,通过观察它在MHC中的操作,然后查看相关的HCONFIG和FTL文件,可以看出它是如何运作的。
以上来自于百度翻译
以下为原文
@Karan,
I'll have to check out the method that Totem has outlined, as I vaguely recall reading about it. As for what I do, I generally take an iterative approach to creating a BSP. The first thing that you should do is find out which one of those DS files in bsp/config corresponds to your processor. You'll find a list of hconfig files here: C:microchipharmonyv2_03butilitiesmhcconfig. Just look for your processor, open it, and the DS file name will be in the first 10 lines or so. You will ultimately add your bsp information to that file so that it shows up. A couple of things to watch out for are the following: make your custom board the default near the top of the DSxxxx file and you may need to add some logic to the very bottom of that file to override some of the _COMMON features.
As for the bsp itself, copy one that you deem to be similar to your project. bsp.hconfig is the file that you'll spend most of your time hacking away at. Before you do anything, though, you'll need to rename some things. I would suggest using textpad, or something similar, to find and replace everything without doing it yourself. Supposing that you have started a project already, take a look at the generated mhc file. You'll find that a lot of those things can be reused in your bsp. I've added not just names of pins, but pps settings, direction, pullups, driver selection/settings, stack selection, etc.
From a big picture standpoint I'll start a project, enable the timer service, and use the SYS_TMR_DelayMS and SYS_TMR_DelayStatusGet functions to create delays so that I can toggle a pin. Looking at this on an oscilloscope, if the toggle frequency matches then I know quite a few things immediately. I know that my clock settings are in order, probably my configuration bits, and certainly the timer system service. I can then poach those settings from the mhc file and put them into the bsp. This means I probably won't have to revisit the configuration bits again.
From here, I'll start adding things to the project and testing them one by one. When something works, I'll go back and add it to the bsp files. To ensure that the bsp does what it should, I'll restart the MHC and NOT select a configuration file when prompted to do so. I'll then check bsp and, since my bsp is the default as outlined earlier, all of the settings that I want will be filled in if I've done it correctly.
In your situation, I can't really stress this painstakingly slow, iterative approach to a project enough. Nearly every time I've started a new project without doing this I've gotten bogged down and started assuming things were working that really weren't. This has been true even pre-Harmony. Since the graphics stack is pretty complicated, you'll want to remove all doubt. You've done well choosing a supported graphics processor and hopefully you've copied the hardware from some Microchip demo board to the letter. This way you can eliminate the hardware when things aren't necessarily working out.
The approach that Totem noted, and the Harmony documentation outlines, is probably far preferable to that which I have written. However, you'll get a pretty good understanding of bsps that will help you in the future. Having a solid bsp for your project regardless of how you obtained it is FAR preferable to starting every project from scratch.
Finally, don't let the free template language scare you. There is definitely documentation from Microchip on that front and in most cases it's pretty simpl to see how it functions by observing its operation in the MHC, and then looking at the related hconfig and ftl files.