发 帖  
原厂入驻New
发烧友10周年庆典,全网超值优惠来袭!千元现金券,下单抽奖赶紧参与》》
[问答] 如何在MPLLABX中设置一个允许使用xc8 v1.38做的项目?
123 引脚 编译器 USB
分享
我正在编写基于微芯片的CDC样本的软件。其中一个要求是,相同的固件(HEX文件)必须在三个不同的芯片上工作。它们非常相似,特别是1454和1455。一个十六进制文件编译的1455个作品没有变化的1454。但不是1459。1459 UART是在另一个端口为RX和TX。固件功能需要USB和RX/TX引脚。所有剩余的引脚只是用作数字/模拟I/O,不需要任何外围功能或中断它们。这种情况似乎使它能够工作。据我所知,只有UART在运行时需要确定,而不需要通过编译器中的定义来确定。我可以检查它在地址0x8006上的哪个芯片。根据这个设备ID的值,我可以计算出我需要使用哪一组端口/寄存器。任何需要什么的指针都很好。我现在的问题是如何在MPLLABX中设置一个允许这么做的项目(使用xc8 v1.38)。

以上来自于百度翻译


      以下为原文

    I am writing software based on the CDC sample from Microchip. One of the requirements is that the same firmware (hex file) has to work on three dIFferent chips. They are very similar especially the 1454 and 1455. A HEX file compiLED for the 1455 works without change on the 1454. But not on a 1459. The 1459 UART is on another port for both RX and TX.

The firmware functionality needs the USB and RX/TX pins. All remaining pins are just used as digital/analog I/O and do not need any peripheral functions or interrupts on them. This condition seems to make it possible to get it to work. As far as i can see only the UART needs to be determined at runtime and not by defines in the compiler.

I can check which chip it is on address 0x8006. Depending on the value of this device id i can figure out which set of port/registers i need to use. Any pointers on what is needed would be nice.

The problem i have at the moment is how to setup a project that allows this in MPLABX (using xc8 v1.38).
The 1459 has the most features, so i guess that is the starting point, but how to proceed from that?
0
2019-7-12 11:35:13   评论 分享淘帖 邀请回答
18个回答
我将从PIC16F1454开始,因为它的特性最少。一旦您创建了HEX文件到您的标准中,就没有别的事情可做了——将它和程序导出到不同的设备上。不太明白“前进”是什么意思。

以上来自于百度翻译


      以下为原文

    I would start from PIC16F1454 because it has the least features. Once you create the HEX file to your standards, there's nothing else to do - export it and program to different devices. Don't quite understand what do you mean by "proceed".
2019-7-12 11:55:10 评论

举报

其中一个要求(遗憾的是,我没有提出)是只有一个十六进制文件。所有三个芯片的存储器设置与大多数寄存器完全相同。1454没有模拟特性,1455/1459没有。1459具有额外的端口(更多的i/o)。要求是当在固件中检测到1455/1459时,一些管脚被用作模拟输入。当检测到1459时,大多数额外的引脚将用于扫描矩阵。该产品将具有可选的部分(如键盘/LCDand,以尽量减少用户(支持)错误,需要单个十六进制文件。在我看来,单个项目的维护比三个更容易。我想我可以在deviceid上进行一些测试,并且当我使用1459作为项目设备时,我可以让它工作。例如,当项目设备是1455时,TRISB不可用,因此它不会编译。当我选择1459时,我可以编译,但如果设备是1454或1455,则必须跳过TRISB设置。最大的未知数是来自微芯片的USB库。最新的是1459,所以至少是相同的起点。希望代码中没有太多,如果为一个特定的芯片定义的。例如:当项目设备不是1459时将不编译。这将编译,但最后我将得到两个十六进制文件。当项目设备是1459时将编译。并且只有当检测到1459时才会执行TrISB= 0xFF。对于所有芯片来说,这将是一个十六进制文件。我关心的是USB库和UART,因为它们有很多条件部分,并且UART管脚位于其他端口上。

以上来自于百度翻译


      以下为原文

    One of the requirement (which i do not make unfortunately) is that there is a single hex file.
The memory setup of all 3 chips is exactly the same as are most of the registers.
A 1454 does not have analog features, a 1455/1459 does. A 1459 has extra ports (more i/o).
The requirement is that when a 1455/1459 is detected in the firmware some pins are being used as analog inputs. When a 1459 is detected most extra pins will be used to scan a matrix. The product will have optional parts (like a keypad/LCD and to minimize user (support) errors a single hex file is required.
On my side maintenance of a single project is easier then three. I think i can do it with a few test on the deviceid, and i think i can get it to work when i use a 1459 as the projects device. For example a TRISB is not available when the projects device is a 1455, so it will not compile. When i choose a 1459 i can compile but then have to skip the TRISB setup if the device is a 1454 or 1455.
 
The biggest unknown is the USB library from microchip. The latest is for the 1459, so that is at least the same starting point. Hoping that there are not to many if defined's for a particular chip are in the code.
 
As an example:

    TRISA  = 0xFF;  //All pins input
    TRISB  = 0xFF;
    TRISC  = 0xFF;

Will not compile when the projects device is not 1459.
 

   TRISA  = 0xFF;  //All pins input
   #if defined(_PIC16F1459_H_)
      TRISB  = 0xFF;
    #endif
    TRISC  = 0xFF;

This will compile but then i end up with 2 hex files.
 

   TRISA  = 0xFF;  //All pins input
   if((DeviceID & 0x03) == 3) {  //test for 1459 device
      TRISB  = 0xFF;
   }
   TRISC  = 0xFF;

This will compile when the projects device is a 1459. And will only execute the TRISB = 0xFF when then 1459 is detected. This will be a single hex file for all chips.
 
My concern is the USB library and UART because those have lots of conditional parts and the UART pins are on other ports.
 
[/code]
 
 
  
 
2019-7-12 12:17:19 评论

举报

你不应该担心UART。它将在不同的引脚上,但是无论如何你都不能改变它。编程也一样,我认为USB也不会有什么不同。它只处理USB寄存器,它们都是一样的。

以上来自于百度翻译


      以下为原文

    You shouldn't worry about UART. It will be on different pins, but you cannot change this anyway. The programming will be the same.
 
I don't think USB would be different neither. It deals only with USB registers, which are all the same.
 
2019-7-12 12:22:19 评论

举报

我只是快速浏览了一下数据表,UART和USB寄存器位于相同的位置,所以它应该工作。我只想将它编码为F1459,但是确保所有变量都分配在实现的数据存储器位置。<edit>所有三个设备具有相同的数据SRAM映射。</edit>关于PORTB、LATB、TRISB、ANSELB和WPUB,它们在'54和'55上没有实现,因此访问它们是没有问题的。

以上来自于百度翻译


      以下为原文

    I just took a quick glance at the datasheet, the UART and USB registers are located at the same locations; so it should work.  I'd just code it as a F1459, <strike>but ensure all the variables are allocated in implemented data memory locations.</strike> <edit> All three devices have the same data SRAM map. </edit> Regarding PORTB, LATB, TRISB, ANSELB, and WPUB they are unimplemented on the '54 and '55 so accessing them is non-issue.
2019-7-12 12:35:08 评论

举报

在1454年,你需要清除ANSELA(即使它不存在),使一些引脚作为输入(不要记住哪些引脚)工作。这是一个硅的错误,由于某种原因没有到勘误表。

以上来自于百度翻译


      以下为原文

    On 1454 you need to clear ANSELA (even though it doesn't exist) to make some of the pins work as an input (don't remember which pins). It's a silicon bug which for some reason didn't make it to errata.
 
2019-7-12 12:55:02 评论

举报

我正在看的Rev BDATHEWET在28页的54页上有安塞拉。

以上来自于百度翻译


      以下为原文

   
The Rev B datasheet I am looking at has ANSELA on page 28 for the '54.
2019-7-12 13:07:20 评论

举报

谢谢你确认我的想法。)我还浏览了几次数据表,似乎可以完成。所有的USB部件看起来都一样。大部分的UART是通过寄存器完成的,而且这三个设备也是相同的。只需要直接控制UART管脚就可以了。(用于中断信号,并将其设置为数字端口,禁用模拟)。我没有使用任何DTR/CTS,这样更容易。我在USB cdc mla中发现了一些专用于1459的定义,但是到目前为止看起来变化很小。还感谢您提醒我禁用1454上的模拟端口。我以前被那个人咬过,很容易忘记。

以上来自于百度翻译


      以下为原文

    Thanks for the confirmation of what i thought/hoped. :)
I also went through the datasheet a few more times and it seems it can be done. All the USB parts seem equal.
Most of the UART is done through registers and those are the same for all three devices.
Only directly controlling the UART pins will need to be handled. (For break signal and setting it up as a digital port and disabling analog). I am not using any DTR/CTS so that makes it easier.
I found a few defines that were specific for the 1459 in the USB cdc mla but so far it looks like a minimal change.
 
Also thanks for the reminder about disabling the analog ports on the 1454. I have been bitten by that before and is easy to forget.
 
 
2019-7-12 13:17:59 评论

举报

HEX文件对于三个不同的PICS的要求是相当危险的,而不需要首先研究它。

以上来自于百度翻译


      以下为原文

    The requirement that a hex file work for three different PICs is quite abitrary and dangerous without researching it first.
2019-7-12 13:30:41 评论

举报

这是研究的一部分。目前,状态是“应该可能的”。需要一些时间才能100%确定,并且必须进行一些测试。一旦测试在所有三个芯片上运行100%(基本cdc功能),那么特定于特定芯片的附加功能将是可能的。

以上来自于百度翻译


      以下为原文

    This is part of the research. At the moment the status is 'should be possible'.
It will take some time to be 100% sure and some tests will have to be made.
Once tests are running 100% (basic cdc functionality) on all three chips then the additional functions specific for a particular chip will be possible.
2019-7-12 13:39:34 评论

举报

研究应该包括为3个不同的图片建立HEX文件并检查结果。并比较内存映射。说它似乎能奏效,可以进行导弹攻击。在ASM中有完全的控制。C可以根据芯片的硬件的不同而不同。

以上来自于百度翻译


      以下为原文

    The research should include building the hex file for the 3 different pics and checking the results. And Comparing the memory maps.
Saying it appear to work can be missileading.
In ASM there is fully control. C may build differently depending on what hardware the chip has.
2019-7-12 13:53:17 评论

举报

是啊

以上来自于百度翻译


      以下为原文

   


yeah
2019-7-12 14:11:58 评论

举报

如果你知道自己在做什么,我不认为这是危险的。

以上来自于百度翻译


      以下为原文

    I don't think it's dangerous if you know what you're doing.
2019-7-12 14:25:27 评论

举报

如何危险取决于所选的3个芯片。微芯片已经知道有一个寄存器,或者位在一个不同的地址。经验测试提出了测试期间代码覆盖的问题。它永远不会是100%。在这种情况下,如果3个芯片在同一个家庭中,共享相同的映射,则微芯片不知道是否有写入未分配寄存器的重叠,并且如果勘误表没有显示差异,那么它可能是可能的而不是危险的。危险的是它可能被再次问及扩展。

以上来自于百度翻译


      以下为原文

   
How dangerous would depend on the 3 chips chosen. Microchip has been known to have a single register, or bit at a different address. Empirical Testing brings up the issue of code coverage during testing. It is never 100%.
In this case if the 3 chips are in the same family, share the same map, microchip is not know to have write to unassigned registers overlap, and if the errata does not show differences , it may be possible and not dangerous at all.

What is dangerous is that it may be asked again and expanded on.
2019-7-12 14:45:00 评论

举报

我只是认为这3个芯片是非常亲密的家庭(同样的数据表!)略有不同。而这些区别只是可以或不能使用的额外能力。在另一篇文章中:一旦代码被写成支持三个芯片,就不可能再为另一个芯片编译。例如,1454没有TRISB寄存器,编译器将因错误而停止。我需要使用很多ifdef用于再次编译,但是确保十六进制输出是不同的。目前我使用1459作为基础,在运行时检查deviceid(0x8006)以执行或跳过部分代码。主要区别。在进一步研究之前,我将先研究和测试一些简单的程序。我考虑过使用ASM,但是决定不使用它,因为在ASM中使用USB是相当困难的。基本的CDC在C中工作良好,它留下大约50%的RAM和50%的Flash可用。剩下的代码在C中是微不足道的,但在ASM中仍然是一个繁琐的工作。

以上来自于百度翻译


      以下为原文

    I only consider it as the 3 chips are very close family (same datasheet!) with minor differences. And those differences are only extra capabilities which can or can not be used.
 
On the other post made:
Once the code is written to support three chips it is impossible to compile for another.
Example the 1454 does not have a TRISB register and the compiler will stop with an error.
I will need to use a lot of ifdefs to get it to compile again but that ensures the hex output will be different.
At the moment i use the 1459 as a base and check the deviceid (0x8006) in runtime to execute or skip parts of the code.
Comparing the registers and memory maps (banks) of the three chips in the datasheet show no major differences.
I will research and test some simple programs first before i go further.
 
I thought about using ASM but decided against it as using USB in ASM is pretty difficult. The basic cdc works good in C and it leaves about 50% of RAM and 50% of flash available.  The rest of the code is trivial in C, but still a chore in ASM.
2019-7-12 15:00:22 评论

举报

编译器将停止一个错误,因为未定义TrISB。您可以有条件地定义并且只有3组定义。我不是说它不能或不能工作。在许多情况下,它可以。一般来说,这是额外的风险。Microchip将不会探索对不存在的TrISB的写入有副作用的可能性。对非即时存储器的写入是惰性的。对我来说,作为一个长期论坛追随者,这是一个很少被问及的问题。未知有风险。只要需求作者理解了风险,他们就可以不退货地承担风险,并表示您说可以工作。

以上来自于百度翻译


      以下为原文

    The compiler will stop with an error because TRISB is not defined.
You could conditionally define and only have 3 sets of defines.
I am not saying it can not or will not work.
In many cases it can.
Just that in general it is additional risk.
Microchip will not explore the possibility that a write to the non existent TRISB has side effects. Is a write to non exinstant memory inert.
To me as a long time forum follower, it is a seldom asked question. The unknown has risks. As long as the authors of the requirement understand that risk they are free to take it without consign back and saying you said it would work.
2019-7-12 15:13:26 评论

举报

是的,这是额外的风险。我不会承诺一个十六进制文件,直到进一步的测试是成功的。测试需要时间,但我认为这也是一个有偿的!学习经验。接下来的几天将会很清楚。如果它不起作用,我的建议是使用三个(1459)中最有能力的芯片,并且只使用那个芯片。我认为拥有一个单独的pcb布局会节省成本,但是我不知道将要使用的数量。我理解需要使它变得简单。负责销售和支持工作。一个软件是便于管理的。

以上来自于百度翻译


      以下为原文

    Yes it is an additional risk. I will not commit to a single hex file until further tests are successful.
The tests take time, but i see that also as a paid! learning experience. The next days will make it clear.
If it does not work my suggestion would be to use the most capable of the three (1459) and only use that chip.
I would think having a single pcb layout would be a cost saver, but i am not privy to the quantities that will be used.
I understand the need to make it easier for sales and support. A single piece of software is for them easier to manage.
 
2019-7-12 15:30:42 评论

举报

CDC样本的第一次测试是在所有三个芯片上进行的。变化非常小,只有一些TrISB设置需要在运行时有条件。测试使用的是针对1459的mla中发现的标准低管脚计数cdc样本。我还期望在研究了芯片的头文件和数据表之后,使用其他i/o管脚作为数字I/O不会造成无法解决的问题。

以上来自于百度翻译


      以下为原文

    A first test of the cdc sample is working on all three chips. The changes were very minimal, only some TRISB settings needed to be conditional at runtime. The test was using the standard low pin count cdc sample found in the mla that is made for the 1459.
I expect also after studying the header files for the chips and the datasheet that using the other i/o pins as digital I/O will cause no unsolvable problems.
 
2019-7-12 15:46:12 评论

举报

我所看到的Rev BasDeSoad在第28页的ASELA在Rev B datasheet中提到,AsSELA和ANSELC都存在1454,所以我认为我们必须在端口A和C的任何操作之前清除它们,我注意到另一个线程正在讨论像AsSelababIt这样的操作。不接受XC8……

以上来自于百度翻译


      以下为原文

   
The Rev B datasheet I am looking at has ANSELA on page 28 for the '54.

</blockquote>


as mentioned in Rev B datasheet,Both ANSELA and ANSELC do exist for 1454,so i think we have to clear both of them before any operation of port A and C.
i noticed that another thread was talking that operation like ANSELAbits.ANSA4 will not be accepted by XC8......
2019-7-12 16:02:53 评论

举报

只有小组成员才能发言,加入小组>>

47个成员聚集在这个小组

加入小组

创建小组步骤

关闭

站长推荐 上一条 /10 下一条

快速回复 返回顶部 返回列表