完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
晚上好,我用的是PIC24FJ128GB202,我需要编程I2C接口。所以我已经包含了i2c.h库文件,但也有一些问题。它似乎没有定义“I2CV11Y1”常量,不能使用包含的函数。我注意到这个文件已经被“PIC24fxPurixFask.h”迷住了。如果我理解正确,它不覆盖PIC24FJ128GB202模型,因为它没有被声明在内部。我该怎么办?你能给我什么建议?我期待着您的回复。
以上来自于百度翻译 以下为原文 Good evening I'm using PIC24FJ128GB202 and I need to program i2c interface. So I have included i2c.h library file, but there are some problem. It seems not defined "i2c_v1_1" constant and the contained functions can't be used. I have noticed this file is addicted to "PIC24F_periph_features.h". If I have understood correctly it doesn't cover PIC24FJ128GB202 model, because it isn't declared inside. How can I do? What can you suggest me? I look forward your response. |
|
相关推荐
14个回答
|
|
|
取决于你要做什么……我在3-4年前通过I2C连接EEPROM芯片有很大的问题。我使用了外围图书馆,但无法使它正常运行。因此,我改为用BIT来代替驱动程序,这是因为我可以使用两个线的I/O引脚。这真的很简单,我花了将近一个星期的时间,才花了一周的时间让它在外围的图书馆里工作。所以搜索“Bang-Bi2C BabAgi”(搜索这里),你会发现很多关于这个问题的帖子。我用了PIC24FJ256GB206,这可能很相似。回到你的控制器。
以上来自于百度翻译 以下为原文 Depends on what you are going to do... I had big problems interfacing an EEPROM chip via i2c 3-4 years ago. I used the peripheral library but was unable to get it going properly. So I switched to bit-banging the driver instead, which has the advantage that I could use any I/O pins for the two lines. It was really simple to do and it took no more than a day after I had spent almost a week trying to get it working through the peripheral library. So search for "bit-bang i2c BobAGI" (search here) and you will find numerous posts on the subject. I used a PIC24FJ256GB206, which is probably very similar to your controller. |
|
|
|
|
|
如果你要咬BAR,那么你也可以使用硬件模块编写你自己的I2C库。事实上,如果你能走到那个路线,SPI更容易写。
以上来自于百度翻译 以下为原文 If you are going to bit-bang then you may as well write your own i2c library using the hardware modules. In fact, spi is easier to write if you can go that route. |
|
|
|
|
|
嗯,是的,没有。我搜索了这个网站,发现了这个网站,它描述了所有的东西,并且有一个示例驱动程序文件。用这个我在很短的时间内适应了我的项目。这种方法的优点是你没有被锁定在某些引脚上,你可以使用一个基本上没有子系统的低端PIC。当然,它的缺点是没有硬件模块来帮助你,所以在传输过程中,你会被捆绑在传输中。
以上来自于百度翻译 以下为原文 Well, yes and no... I searched the web and found this site which described it all and has an example driver file. Using this I adapted to my project in very little time. The advantage of this approach is that you are not locked in to certain pins and you can use a low-end PIC with basically no subsystems. The downside of course is that there is no hardware module to help you so you get tied up in the transfer while it lasts. |
|
|
|
|
|
糟透了!因此,我不能使用任何外围图书馆的微芯片,这个UC?我真的需要对每个寄存器进行编程吗?
以上来自于百度翻译 以下为原文 Oh terrible! So I can't use any peripheral library by Microchip, for this uC? Really do I have to program every register needed? |
|
|
|
|
|
当一个新的PIC不被支持时,我通常会从一个更旧的类似设备(例如:在你的情况下为GB102)中从旧的PLIB中获取旧代码,并应用相关的更改(如果有的话)。或者至少从那里得到提示,从而开发出自己的代码。
以上来自于百度翻译 以下为原文 When a newer PIC is not supported, I usually grap old code from PLIB for an older, similar device (say: GB102 in your case) and apply the relevant changes (if any). Or at least take hints from there, and hence develope your own code. |
|
|
|
|
|
这个PIC是另一个PIC(PIC18F67 J60)的替换,它被用在同一个板上。我已经从那个PIC移植了代码。因此,这是一个功能代码,它只是移植到一个不同的微控制器。两个芯片的SPI外围应该是相同的。主要的区别是PPS寄存器的存在。这里有趣的是PIC的其他SPI接口在主模式下作为SPI完全发挥作用。
以上来自于百度翻译 以下为原文 This PIC is a replacement of another PIC (PIC18F67J60), which was used on the same board. I have ported the code from that PIC. Therefore this is a functional code, which is just ported to a different microcontroller. The SPI peripheral of both chips should be identical. The main difference is the presence of the PPS registers. What is interesting here is the other SPI interface of the PIC is fully functional as SPI in Master mode. |
|
|
|
|
|
多谢。我想了一些类似的,但我不知道如何开始。所以PLIB是包含所有硬件定义的主要“载体”。如果我理解我应该复制一个旧的UC文件(比如PIC24F/H/PIC24FJ128GB102.H),根据数据表(“内存组织”一节)修改每一个定义,重新定义寄存器地址。这是正确的吗?
以上来自于百度翻译 以下为原文 Many thanks. I thought something similar, but I didn't know quite how to start. So PLIB is the main "carrier" that contains all hardware definitions. If I have understood I should duplicate an older uC file (like PIC24F/H/PIC24FJ128GB102.h), modify every definition according on datasheet ("MEMORY ORGANIZATION" paragraph), redefine register addresses. Is it correct? |
|
|
|
|
|
嗯,不:H文件包含所有的硬件寄存器定义,这些文件对于任何PIC都是有效的。外设库在仍然保存它们的旧版本中——我使用一个旧的C30安装它们——在编译器的SRC文件夹中,一个名为PurialAlx24f.zIPzip zip的文件。包含所有外围设备的来源:相关。h也在附近。
以上来自于百度翻译 以下为原文 Hmmm, no: that .h file contains all hardware registers definition - and those are always valid for any PIC. Peripheral libraries are, inside old versions of compiler that still carry them - I use an old C30 install for them - inside SRC folder of the compiler, a file named peripheral_24F.zip This zip contains sources for all peripherals: related .h are there around too. |
|
|
|
|
|
好吧,我按照你的建议行动。我得到最简单的模块:Time1。我已经配置了寄存器,但我对设置时间段有疑问。我认为这是方法,但我不确定:TimeIn期/(预分频器)*(CKKYUC)。我配置PRR1寄存器到结果值。“TimeType”是计时器间隔(当它被召回计时器中断)。Prescaler被设置为“00”(即1∶1),所以它应该是1。“CKKYUC”是外部12MHz石英用作主振荡器。我在等待您的消息。
以上来自于百度翻译 以下为原文 Ok, I'm moving as you suggest. I get the simplest module: Timer1. I have already configured registers, but I have a doubt about setting time period. I think this is the way but I'm not sure : time_period / (prescaler) * (clk_uC). I configure PR1 register to the resulting value. "time_period" is the timer interval (when it's recalled the timer interrupt). Prescaler is set to '00' (i.e. 1:1) so it should be 1. "clk_uC" is the external 12MHz quartz used as primary oscillator. I'm waiting for your news. |
|
|
|
|
|
你的外部XTAL可能是12MHz,但是你需要你的FCY来计算时间。PS值是1,8,64,256FCy / PSif fcy是40MHz,然后是256的PS=0 00000,6,4秒1 / 40000000×2560.2秒/ 0 00000,4=31250(五分之一秒)。
以上来自于百度翻译 以下为原文 Your external xtal maybe 12MHz but you need your fcy to calculate the timing. PS values are 1,8,64,256 fcy / PS if fcy is 40MHz then a PS of 256 = 0.000,006,4 sec 1/40,000,000*256 0.2 secs / 0.000,006,4 = period of 31,250 (one fifth of a second) |
|
|
|
|
|
对不起,我忘了在配置位中指定PLL的设置。PLL是禁用的。
以上来自于百度翻译 以下为原文 Sorry, I forgot to specify the setting for PLL in config bits. PLL is disabled. #pragma config PLLDIV = DISABLED So I think my "PS" is 1. |
|
|
|
|
|
我认为你正在改变你的FoSC让你的计时器工作。这就是为什么你有预分频器。你还没有提供足够的信息。所以你的FoCC是12MHz?(FCY是FoSC/2),每指令2个时钟。秒后的定时器值是多少?Anycase,如果你的FCY为6MHz,预分频器为1,这将给你一个周期:0:000000、1666、66、6、7、0、10、9、2、2666、66、88、51、2秒。(Web2.0 Calc)
以上来自于百度翻译 以下为原文 I think you are changing your fosc to make your timer work. That's why you have prescalers. You haven't supplied enough information. So your fosc is 12MHz? (fcy is fosc/2), 2 clocks per instruction. What timer value are your after in seconds? Anycase, if your fcy is 6MHz with a prescaler of 1, that would give you a period in the range of: 0.000,000,166,666,666,7 to 0.010,922,666,668,851,2 seconds. (web2.0 calc) |
|
|
|
|
|
泰恩!在这里你是我的设置,FIG IESO=PARDIMAGICOMG COMPION CONFIMA COMPIG CONFIG配置,WDTPS= PS327 68,PrAPMA配置,FWPSSA=PR128α-PrAPMA CONFIG WORISIS=Off-PracMA配置FFDTEN=OX-PracxMig-COMIGG ICS=PGX1* PrimaA配置文件GWRP=OX-Prima配置文件GCP=Off-AX-PracMA配置JTAGEN=非外部石英12MHz;S定时器1配置:T1CONNE= 0B000 000 000亿;T/CONTION T1CONTITS。TGATE=0;//门控模式关闭T1CONTITS.TSIDL=1;//当控制器处于睡眠T1CONTITY时停止/ TCPKPS1=0;/PASCALE 1 T1CONTS.TCKPS0=0;T1CONBITS TCS=0;LoNealNeTealTime= 0;长CKLYG=FCYSIG;浮点周期=0×00000;INPosiCalter=1;N2=周期/((浮点)(预分频器))*((浮点)(CKLYG));N2= N2+0.5;//ARARSONDO,每次ECSESO周期时间=(无符号INT)(N2);我的目的是获得5US时间周期。怎么了?
以上来自于百度翻译 以下为原文 Thans! Here you are my settings #pragma config WPFP = WPFP127 #pragma config WPDIS = WPDIS #pragma config WPCFG = WPCFGDIS #pragma config WPEND = WPENDMEM #pragma config POSCMD = HS #pragma config IOL1WAY = ON #pragma config OSCIOFCN = OFF #pragma config FCKSM = CSDCMD #pragma config FNOSC = PRI #pragma config IESO = ON #pragma config PLLDIV = DISABLED #pragma config WDTPS = PS32768 #pragma config FWPSA = PR128 #pragma config WINDIS = OFF #pragma config FWDTEN = OFF #pragma config ICS = PGx1 #pragma config GWRP = OFF #pragma config GCP = OFF #pragma config JTAGEN = OFF External quartz is 12MHz; this is timer 1 config: T1CON = 0b0000000000000000; T1CONbits.TON = 1; //Timer ON T1CONbits.TGATE = 0; //Gated mode OFF T1CONbits.TSIDL = 1; //Stop when controller is in sleep T1CONbits.TCKPS1 = 0; //Prescale 1 T1CONbits.TCKPS0 = 0; T1CONbits.TCS = 0; I set PR1 with this expression: #define FCY_g 12000000UL unsigned int periodTime = 0; LONG clk_g = FCY_g; float period = 0.000005; int prescaler = 1; n2 = period / ((float)(prescaler)) * ((float)(clk_g)); n2 = n2 +0.5; //Per arrotondare per eccesso periodTime = (unsigned int)(n2); my purpose is obtain 5us time period. What's wrong? |
|
|
|
|
|
很多。就像我说的,你把MPU时钟放在一个周期内,当它应该是另一个方向的时候。去掉浮点的东西。我已经向你展示了计算。为什么你需要FCY这么低?如果你使用固定的周期,那么在计算器上做,而不是在代码中。59的PRX应该是好的,用1 @ 6MHz fCy的预分频器(假设你的MPU鳍乘法器是1)。
以上来自于百度翻译 以下为原文 A lot. Like I said, you are setting your mpu clock around the period when it should be the other way round. Get rid of the floating point stuff. I've showed you the calculations. Why do you need fcy to be so low? If you are using a fixed period, do it on a calculator not in code. PRx of 59 should be fine for 5us with a prescaler of 1 @6MHz FCY. (assuming your mpu FIN multiplier is 1) |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 03:24 , Processed in 1.051840 second(s), Total 98, Slave 81 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1464