完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我想知道如果我能用PIC18F26K40看到一个问题,我用MCC设置I2C。我所要做的就是在I2C线上发送一条写信息。该消息是0x44,0x01,0x01},地址为0x44。我创建了一个ArayuIt88t A(3)={0x44,0x01,0x01};然后是CALL2C1YMasMrdScript(A,3,0x44,and Stabs1);现在在模拟器中,一个数组被正确地发送给函数,并且我可以看到数组是*pDATA,但是在硬件中,数组是N。OT被发送到函数,所以我在I2C线上看到的是0x88(它是正确的,0x44是7位地址加上一个写入位),后面是3个0x00的消息。我无法在模拟器中测试这一点,因为I2C在发送地址后不会中断模拟器。当我检查MestWrrand函数中的数据时,我会切换一个PIN,所以我知道pDATA永远不会设置在硬件中。如果我设置pdata,当我检测到没有收到任何数据,那么第二次围绕引脚切换两次,正确的数据被从I2C线路发送出去。但是,我不能改变我想发送的数据,因为它是在i2c.c文件内部设置的。我使用的是MPLAB X 3.51、XC8 1 1.40PRO和MCC 3.26.2。
以上来自于百度翻译 以下为原文 I was wondering if I could get some help on a problem I’m seeing with a PIC18F26k40 while I’m setting up the I2C using MCC. All I want to do is send a write message on the I2C line. The message is {0x44, 0x01, 0x01} with the address of 0x44. I created an array uint8_t a[3] = {0x44, 0x01, 0x01}; then call I2C1_MasterWrite(a, 3, 0x44, &status1); Now in the simulator the a array gets sent correctly to the function and I can see the array as *pdata, but in hardware the array does not get sent to the function, so what I see on the I2C line is 0x88 (which is correct as 0x44 is the 7 bit address with a write bit added in) followed by 3 messages of 0x00. I can’t test this in the simulator as the I2C never interrupts the simulator after the address is sent. I toggle a pin when I check the data in the MasterWrite function so I know that pData is never set in hardware. If I set pdata when I detect nothing is received then the second time around the pin toggles twice and the correct data gets sent out of the I2C line. However, I cannot change the data I want to send as it is set internally to the i2c.c file it seems. uint8_t Start[3] = {0x44, 0x01, 0x01}; void main(void) { SYSTEM_Initialize(); uint8_t Address = 0x44; I2C1_MESSAGE_STATUS status1 = I2C1_MESSAGE_PENDING; waitForDevice(); while (1) { wait150ms(); I2C1_MasterWrite(Start, 3, Address, &status1); while(status1 == I2C1_MESSAGE_PENDING); } } void I2C1_MasterWrite(uint8_t *pdata,uint8_t length,uint16_t address,I2C1_MESSAGE_STATUS *pflag) { static I2C1_TRANSACTION_REQUEST_BLOCK trBlock; // check if there is space in the queue if (i2c1_object.trStatus.s.full != true) { if (*pdata == 0x44) { LED1_Toggle(); LED1_Toggle(); } else if (*pdata == 0) { LED1_Toggle(); *pdata = 0x44; pdata++; *pdata = 0x01; pdata++; *pdata = 0x01; pdata--; pdata--; } I2C1_MasterWriteTRBBuild(&trBlock, pdata, length, address); I2C1_MasterTRBInsert(1, &trBlock, pflag); } else { *pflag = I2C1_MESSAGE_FAIL; } } I’m using MPLAB X 3.51, XC8 1.40 PRO, and MCC 3.26.2 |
|
相关推荐
3个回答
|
|
|
我刚刚发现,在硬件中没有初始化数组,但是它在模拟器中运行。目前的工作是,在发送到主写函数之前,有一个初始化例程来设置数组。
以上来自于百度翻译 以下为原文 I just found out that uint8_t Start[3] = {0x44, 0x01, 0x01}; does not initialize the array in hardware, but it does in the simulator. The work around for now is to have an initialization routine to setup the array before sending it to the Master Write function. |
|
|
|
|
|
编译器生成相同的代码。很有可能你的PIC18F26K40被一个勘误表影响了。你可以寻找它,或者得到一个新的编译器,假设它有一个修复。
以上来自于百度翻译 以下为原文 The Compiler generates the same code. It is likly your PIC18F26k40 is affected by an errata. You can seach for it, or get the Newer compiler that is suppose to have a fix for it. |
|
|
|
|
|
看看下面的链接…这应该有帮助:)HTTP://www. McCHIP.COM/FUMMS/M98227.ASPX
以上来自于百度翻译 以下为原文 Check out the following link... This should help :) http://www.microchip.com/forums/m985227.aspx |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
501 浏览 0 评论
5808 浏览 9 评论
2350 浏览 8 评论
2237 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3543 浏览 3 评论
1155浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1119浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
887浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
501浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-12 04:12 , Processed in 0.992674 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1479