This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3235SF: 关于在定时器中断中进行IIC读写的时候,使用IIC读写失败?

Part Number: CC3235SF

我使用CC3235SF的定时器中断去读取数据的时候,进入中断后,在IIC读取数据函数上数据读取失败,但是不在中断里去读取数据时却能正常进行寄存器读写,这是为什么呢?

定时器初始化

中断调用数据读取接口

  • I2C使用的是阻塞还是回调模式,I2C_transfer()只会返回true或false,Null是怎么来的:

    bool I2C_transfer	(	I2C_Handle 	handle,
    I2C_Transaction * 	transaction 
    )		
    Perform an I2C transaction with an I2C slave peripheral.
    
    This function will perform an I2C transfer, as specified by an I2C_Transaction structure.
    
    Note
    When using I2C_MODE_BLOCKING, this must be called from a thread context.
    Parameters
    [in]	handle	An I2C_Handle returned from I2C_open()
    [in]	transaction	A pointer to an I2C_Transaction. The application is responsible for allocating and initializing an I2C_Transaction structure prior to passing it to I2C_Transfer(). This structure must persist in memory unmodified until the transfer is complete.
    Note
    I2C_Transaction structures cannot be re-used until the previous transaction has completed. Upon the completion of a transaction, the I2C_Transaction.status may be used for error handling.
    Returns
    In I2C_MODE_BLOCKING: true for a successful transfer; false for an error (for example, an I2C bus fault (NACK)).
    In I2C_MODE_CALLBACK: always true. The I2C_CallbackFxn bool argument will be true to indicate success, and false to indicate an error.

    另外注意定时器定时时间内是否可以读完数据

  • i2c用的是默认的模式,应该是BLOCKING模式,那返回的就是false,执行完transfer之后返回值就是false,我定时时间延迟也不行。

  • 如果将IIC的工作模式设置成callback模式,那么这个callbackfxn是什么呢?这个函数是实现什么功能呢?

  • 请问这个callbackfxn的作用是什么呢?我应该怎么写这个callbackfxn函数

  • 在中断程序中不应有任何形式的阻塞,这可能会导致中断程序不能及时处理

    请问这个callbackfxn的作用是什么呢?我应该怎么写这个callbackfxn函数

    callback说明及使用查看里面的说明:https://dev.ti.com/tirex/content/simplelink_cc32xx_sdk_5_20_00_06/docs/drivers/doxygen/html/_i2_c_8h.html

  • 我设置了i2c成callback模式之后,我的iIC读写函数不能读写了,读出来的数据都是0,可以帮我看看是什么原因嘛

  • 您能帮我看看哪里有问题嘛,为什么我将i2c设置成callback方式后就不能进行正常的读写操作了呢,之前是blocking模式的时候是可以正常进行读写操作的

  • 您好,为啥将iic设置成callback模式后,iic的读写函数就不能用了呢?帮我看看呗

  • 是读不行还是写不行,亦或是都不行,单步调试会在哪一步出现问题?

    请注意callback中的信号量依然可能阻塞,最好是将I2C读写从中断中拿出来单独处理

  • 就是我执行到定时器中断去读取数据时,还是在定时器中断里用iic去读取数据出问题,之前将iic设置成blocking模式的时候就是卡在了定时器中断读取数据函数这里,现在将iic改设置成callback模式还是一样卡在了这里。请尽快帮忙看下是什么问题呢?

    程序卡在了这里

  • 怎么解决呢

  • 在等待信号量,所以还是阻塞,需要从中断中拿出来处理

    论坛帖子比较多,如上次所说,目前人手有限。如果比较问题比较多,请直接在英文论坛发帖或者联系当地TI FAE