[求助]關(guān)于mCH341A_CMD_I2C_STM_OUT這一控制命令

EXAM.C里很多地方都用到了I2C接口的命令流:mCH341A_CMD_I2C_STM_OUT

這個(gè)命令流在CH341DLL.H中的注釋是:I2C接口的命令流:輸出數(shù)據(jù),位5-位0為長(zhǎng)度,后續(xù)字節(jié)為數(shù)據(jù),0長(zhǎng)度則只發(fā)送一個(gè)字節(jié)并返回應(yīng)答。

我自己編寫了一個(gè)簡(jiǎn)單的往24c02里寫數(shù)據(jù)的函數(shù)如下: BOOL WriteEEPROM( ULONG iIndex) { UCHAR mBuffer[ mCH341_PACKET_LENGTH ]; ULONG mLength; mBuffer[ 0 ] = mCH341A_CMD_I2C_STREAM; mBuffer[ 1 ] = mCH341A_CMD_I2C_STM_STA; mBuffer[ 2 ] = (UCHAR)(mCH341A_CMD_I2C_STM_OUT| 6);

mBuffer[ 3 ] = 0xa0; //控制碼

mBuffer[ 4 ] = 0x00; // 雙字節(jié)地址 mBuffer[ 5 ] = 0x00; mBuffer[ 6 ] = 0x11; // 數(shù)據(jù) mBuffer[ 7 ] = 0x22; mBuffer[ 8 ] = 0x33; mBuffer[ 9 ] = 0x44;

mBuffer[ 10 ] = mCH341A_CMD_I2C_STM_STO; mBuffer[ 11 ] = mCH341A_CMD_I2C_STM_END; mLength = 11; CH341WriteData( iIndex, mBuffer, &mLength ); } 該函數(shù)可以從EEPROM的起始位置寫入數(shù)據(jù) 11223344。中間從 mBuffer[ 3 ]~ mBuffer[ 9 ] 的地方共有7個(gè)數(shù)據(jù),而經(jīng)過(guò)測(cè)試,只有用mCH341A_CMD_I2C_STM_OUT|6 才能正常寫入,如果用mCH341A_CMD_I2C_STM_OUT|7 是不行的。 可是在EXAM.C中,好象凡是發(fā)送N個(gè)數(shù)據(jù)的地方,都是用的mCH341A_CMD_I2C_STM_OUT| N,那么到底 mCH341A_CMD_I2C_STM_OUT的長(zhǎng)度是怎么定義的呢?

問(wèn)題已經(jīng)解決了,是我自己的程序有問(wèn)題,應(yīng)該是發(fā)N個(gè)字節(jié)就用mCH341A_CMD_I2C_STM_OUT| N


頂?。?/p>


發(fā)N個(gè)字節(jié)就用mCH341A_CMD_I2C_STM_OUT| N,在你的程序中不是7個(gè)字節(jié)嗎? 怎么要用mCH341A_CMD_I2C_STM_OUT| 6才可以呢?? 奇怪?。。? 你能說(shuō)說(shuō)是怎么解決的嗎??


應(yīng)該是mCH341A_CMD_I2C_STM_OUT|7才對(duì)啊??! 怎么會(huì)一定要mCH341A_CMD_I2C_STM_OUT|6才可以正確執(zhí)行呢!???? 你是怎么作的??


原來(lái)的程序有錯(cuò)誤,所以用mCH341A_CMD_I2C_STM_OUT|6才能通過(guò).


樓主程序中mLength = 11;應(yīng)該是12而不是11, 如果是普通的EEPROM,建議用現(xiàn)成的Read/WriteEEPROM效率高


對(duì)??!mLength = 12 還有什么錯(cuò)誤會(huì)導(dǎo)致只能用mCH341A_CMD_I2C_STM_OUT|6,而不是mCH341A_CMD_I2C_STM_OUT|7呢? 實(shí)在想不出還有什么錯(cuò)誤了??!呵呵


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频