完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用MCC生成的代码,用于我的原型板上的DSPIC33 EP64 GP502处理器。问题是I2C2_MasterWrite()函数总是生成TRAPS_._on_error,在下面的函数中值为2:void_.((na.,noreturn,.))TRAPS_._on_error(uint16_t代码){TRAPS_error_code=code;...MCC生成文件mcc.c和i2c2.c,等等,这启发了我使用I2C2SmithWrreWrand()函数。谁能帮我弄清这个陷阱的原因?我用Google找不到任何信息来理解TRAPS_._on_error的错误。我用示波器使用标准的_LATB14和_LATB15函数用位脉冲实现来验证I2C时钟和SDA信号的信号完整性,并且看到SDA和SCL信号随着程序摇摆。阿默德但是,使用MCC生成的函数,这些相同的信号甚至没有摆动。我验证我正在交谈的从设备(PCA9685)是使用启用信号上的示波器启用的。产生错误的相关代码如下所示,main(void){//初始化设备SYSTEM_In(); //*指定为输出*/_TRISB1=0;//RB1_TRISB4_TRISB4=0;//RB4_TRISB4 13131313131313130;//RB4_RB4_TRISB13 131313131313131313131313131313131313131313130;//RB14_TRISB14_TRISB15131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131316PCA9685_PCA9685_TRISB15=0;////RB14_TRISB1414141414141414131313131313131313131313131313阿里OSCILLATOR_Initialize();OSCILLATOR_Initialize();UART2_Initialize();SPI1_Initialize();UART1_Initiitialize();I2C2_Initialize();I2C2_III2C2_初始化();EXT_INT_INT_InInitialize();TMR1_Initialize_Initialize();TMR1_Initialize_Initialize();INTERRUPT_InInitialize(;INTERRUPUPUPUPUPUPT_GlobalEnEnEnEnEnEn();INTERRUPUPUPUPUPUPUPUPUPUPUPUPUPT_TTTTTTTTTTTTTTE_GlobalEnEnEnEn_STATUS状态=I2C2_MESSAGE_PENDING;uint16_t从设备地址=SLAVE_DEV_ADDRESS;WriteData[0]=(MODE1>8);//PCA9685子地址WriteData[1]=(uint8_t)(MODE1);WriteData[2]=0b00110001;//按照i2c2.h I2C2_MasterWriteData中描述的相同函数调用格式将模式设置为.//,3,SLaveDeVice地址,和状态);//结果在TrrspHaltTynOnLoad…}中的结果
以上来自于百度翻译 以下为原文 I am using code generated by MCC for the dsPIC33EP64GP502 processor on my prototype board. The problem is that the I2C2_MasterWrite() function always generates a TRAPS_halt_on_error with the value of 2 in the following function: void __attribute__((naked, noreturn, weak)) TRAPS_halt_on_error(uint16_t code) { TRAPS_error_code = code; ... MCC generated the files mcc.c and i2c2.c, among others, which inspired me to use the I2C2_MasterWrite() function. Can anyone help me understand the cause of this trap? I couldn't find any information using Google to understand the error TRAPS_halt_on_error. I verified the signal integrity of the I2C clock and SDA signals using oscilloscope using a bit banged implementation using standard _LATB14 and _LATB15 functions and saw the SDA and SCL signals wiggle as programmed. However, using the MCC generated functions, these same signals did not even wiggle. I verified that the slave device I am talking to (PCA9685) is enabled using an oscilloscope on the enable signal. The pertinent code generating the error is as follows int main(void) { // initialize the device SYSTEM_Initialize(); /* Specify as outputs */ _TRISB1 = 0; // RB1 _TRISB4 = 0; // RB4 _TRISB13 = 0; // ~OE for PCA9685 _TRISB14 = 0; // RB14 _TRISB15 = 0; // RB15 pca9685_init(); ..... The code produced by MCC for SYSTEM_Initialize is: void SYSTEM_Initialize(void) { PIN_MANAGER_Initialize(); INTERRUPT_Initialize(); OSCILLATOR_Initialize(); UART2_Initialize(); SPI1_Initialize(); UART1_Initialize(); I2C2_Initialize(); EXT_INT_Initialize(); TMR1_Initialize(); INTERRUPT_GlobalEnable(); CORCON_ModeOperatingSet(CORCON_MODE_PORVALUES); } int pca9685_init() { uint8_t WriteData[3]; I2C2_MESSAGE_STATUS status = I2C2_MESSAGE_PENDING; uint16_t slaveDeviceAddress = SLAVE_DEV_ADDRESS; WriteData[0] = (MODE1 >> 8); // PCA9685 Subaddress WriteData[1] = (uint8_t)(MODE1); WriteData[2] = 0b00110001; // Setting mode to sleep // following the same function call format described in i2c2.h I2C2_MasterWrite( WriteData, 3, slaveDeviceAddress, &status); // Results in TRAPS_halt_on_error ... } |
|
相关推荐 |
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
727浏览 1评论
612浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
501浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
626浏览 0评论
524浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 07:08 , Processed in 1.330775 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号