当前位置:文档之家› can模块手册(协议部分)

can模块手册(协议部分)

6 i CAN

6.1䗮䆃 䆂 ⱘḐ

i CAN῵ 䗮䆃 䆂Ё 䞛⫼ Ḑ ˈ ѢCAN ⱘ29ԡ 䆚ヺ ⱘՓ⫼䛑԰њњ䆺㒚ⱘ㾘 DŽ䗮䆃 ⱘḐ 㾘 㸼 6.1 ⼎˖

㸼 6.1 Ḑ

䇈 ϟ˖

1ˊ㡖⚍㓪 ˄MAC ID˅

㡖⚍㓪 ˄MAC ID˅Ў䆒 㔥㒰Ϟⱘ ϔ 䆚ˈ 䜡Ў8ԡˈ㣗 Ў0x00-0xFEˈ0xFF԰Ў⡍⅞⫼䗨DŽϔϾ㔥㒰 254Ͼ㡖⚍DŽ 䗮䆃 Ё䗮䖛 њ 䗕㡖⚍ 㡖⚍ⱘ㓪 䇈 䗮䆃ⱘ Ϣ㗙DŽ

z SrcMACID (⑤㡖⚍㓪 )˖ 䗕㡖⚍ⱘ㓪 ˈ 䜡8ԡˈ 㣗 Ў˖0x00-0xFEDŽ

⑤㡖⚍ⱘID

z DestMACID (Ⳃ 㡖⚍ )˖ 㡖⚍ⱘ㓪 DŽ 䜡8ԡˈ 㣗 Ў˖0x00-0xFFDŽ DestIDЎ0xFF ˈ㸼⼎ ⃵ 䗕ⱘ DŽ ϡ䳔㽕 ㄨDŽ

2ˊACK˄ ԡ˅

3ˊFUNC ID˄ 㛑ⷕ˅

FUNC ID˖ 㛑ⷕˈ 䜡4ԡDŽ 㛑ҷⷕ⫼Ѣ ⼎ ⱘ 㛑ˈ 㛑ⷕ㾕㸼 6.2˖

㸼 6.2 㛑ⷕ 㸼

4ˊ Source ID˄䌘⑤㡖⚍ 㓪 ˅

Source ID˄䌘⑤㡖⚍˅˖⫼Ѣ ⼎ ԰ⱘ䆒 䚼 ˈ 䜡8ԡDŽ 䆂Ё䌘⑤㡖⚍ Ўϸ㉏ ˖I/O ҹ 䜡㕂 DŽ 䆂Ё䌘⑤㡖⚍ⱘ ⫼256 㡖ぎ䯈DŽ 䆂Ё Нⱘ䌘⑤㡖⚍ ϟ㸼 ⼎˖

㸼 6.3 䌘⑤ 㸼

䜡㕂䌘⑤㡖⚍㓪 㣗 0xE0-0xff˗䜡㕂 Џ㽕⫼Ѣ䆒 ⱘ 䆚 ǃ䗮䆃 ҹ IO DŽ䜡㕂䌘⑤ 㸼 ϟ˖

㸼 6.4 䜡㕂䌘⑤ 㸼

5ˊRTR

䖰⿟ 䆚ˈ 䆂Ё䆒㕂Ў0ˈ ϡՓ⫼䖰⿟ Ḑ DŽ

6ˊ 䚼 ˄Byte0-Byte7˅

ⱘ ˈ ҹ 8Ͼ 㡖 ˗Byte0⫼԰ ҷⷕˈ↣ ⱘ 䖒7ϾDŽ ⡍ ⱘ ЁˈByte1㹿⫼԰LengthFlagǃErrIDㄝ DŽ

z Byte0˄SegFlag˅

䚼 ㄀ϔϾ 㡖Byte0ЎSegFlag˖ ҷⷕDŽ ҷⷕSegflag䆒 ⱘĀByte 0”ԡ㕂ˈ⫼Ѣ ⦄Ā ↉ āḐ ⱘ Ӵ䕧ˈ ↉ 䳔㽕Ӵ䗕 Ѣ7Ͼ 㡖䭓 ⱘՓ⫼DŽ

⃵ Ӵ䕧≵ ↉DŽ

䞣 Ӵ䕧ⱘ㄀ Ͼ ↉˗ℸ ˈ6HJ1XP [ DŽ

Ё䯈 ↉DŽ6HJ1XP Ң [ 䍋ˈ↣⃵ ˈҹ ↉ DŽ

↉DŽ6HJ1XP DŽ

䇈 ˖ 䞛⫼ ↉Ӵ䕧ˈ㄀1 ↉ⱘSegFlag=0x40ˈ ⱘ ↉SegFlag=0xC0 DŽ Ӵ䗕 ˈ 㡖⚍(Ⳃ 㡖⚍) ԧⱘ 1 DŽz Byte1˄LengthFlagǃErrID˅

LengthFlag˖ Ā䇏ッ ā ҸЁ ⦄ˈ 䜡1Ͼ 㡖ˈԡѢ Byte1ԡ㕂DŽLengthFlag㸼⼎䳔㽕䇏ⱘ 㡖 DŽ

ErrID˄䫭䇃 ⷕ˅˖ 䫭䇃 ЁՓ⫼ˈ⫼Ѣ䇈 䫭䇃 ⱘ㉏ ˖

6.2῵ 䗮䆃䖲 ⱘ ゟ

Ў ⦄Ϣ䆒 ⱘ䗮䆃ˈЏ 䆒 乏佪 ゟϢ䆒 ⱘ䗮䆃䖲 ˈ✊ ҹϢ䆒 䖯㸠 Ѹ DŽ 䆹⢊ ϟˈЏキϢҢキ ゟ䗮䆃ⱘ䖛⿟ ϟ 6.1 ⼎˖

6.1 䖲 ゟ⼎

6.2.1 ゟ䖲

Ā ゟ䖲 ā Ҹ ⫼ѢЏキ䆒 ゟϢҢキ䆒 П䯈ⱘ䗮䆃ˈ䗮䖛 Ѣ䌘⑤㡖⚍0xF7䆓䯂 ⦄ⱘDŽ

zĀ ゟ䖲 ā Ҹ Ḑ ϟ˖

䇈 ˖ Ā ゟ䖲 ā Ҹ Ё⑤㡖⚍ ЎЏキMACIDˈ 䭓 Ў3Ͼ 㡖ˈ ㄀ϔϾ 㡖㸼⼎ ↉ⷕ 䆚ˈ ㄀ѠϾ 㡖㸼⼎Master MACID˄Ϣ⑤㡖⚍MACIDϔ㟈˅ˈ ⱘ㄀ϝϾ 㡖㸼⼎Џキ ⦃ ˄CyclicMaster˅DŽ

⊼ ˖ CyclicMaster>0 ˈ˄CyclicMaster*4˅ 䯈ЎҢキ Џキ 䗕䗮䆃 ⱘ 䍙 ⱘ 䯈䯈䱨˗ 䗮䆃䖛⿟ЁˈҢキ Џキ䗮䆃 䍙 ˈ 㞾 䰸䖲 ˈ䗔 䗮䆃

䇈 ˖Ңキ ⱘ Ҹ ⊩ⱘˈϨℷ⹂ ⧚ ↩ˈ 䖨 ℷ ˗ 䚼 Ёˈ㄀ϔϾ 㡖㸼⼎䆒 ЁDI 䭓 ˈ㄀ѠϾ 㡖㸼⼎䆒 ЁⱘDO 䭓 ˈ㄀ϝϾ 㡖㸼⼎䆒 ЁⱘAI 䭓 ˈ㄀ Ͼ 㡖㸼⼎䆒 ЁⱘAO 䭓 DŽ

䇈 ˖ Ңキ Ā ゟ䖲 ā Ҹ ˈ Ңキ 㒣Ϣ ҪЏキ ゟ䖲 㗙 Ҹ 䫭䇃ˈ 䖨 䫭䇃 DŽ Ёҹ䫭䇃 㸼⼎ˈ ЁⱘERRID⫼Ѣ䇈 䫭䇃㉏ DŽ

z⼎՟

ҹ⑤㡖⚍(0x00) Ⳃ 㡖⚍(0x15)ⱘ ゟ䖲 ҸЎ՟ˈ ҹ䇈 DŽ㡖⚍˄0x15˅Ў8 䞣䕧 8 䞣䕧 ˈЏキ䗮䆃 䆒㕂Ў0xFFDŽ

6.2.2 䰸䖲

Ā 䰸䖲 ā Ҹ ⫼ѢЏキ 䫔ϢҢキ ゟⱘ䗮䆃DŽ

䇈 ˖ Ā 䰸䖲 ā Ҹ Ё 䭓 Ў2Ͼ 㡖ˈ ㄀ϔϾ 㡖㸼⼎ ↉ⷕ 䆚ˈ ㄀ѠϾ 㡖㸼⼎Master MACIDDŽ

⑤㡖⚍ Ⳃ 㡖⚍ $&. 㛑ⷕ˖ [ 䌘⑤㡖⚍

[)

↉ⷕ

6HJIODJ [

䇈 ˖Ңキ ⱘ Ҹ ⊩ⱘˈϨℷ⹂ ⧚ ↩ˈ 䖨 ℷ ˗

䇈 ˖ Ңキ Ā 䰸䖲 ā Ҹ ˈ Ңキ ≵ ゟ䖲 㗙 Ҹ 䴲⊩ˈ 䖨 䫭䇃 DŽ Ёҹ䫭䇃 㸼⼎ˈ ЁⱘERRID⫼Ѣ䇈 䫭䇃㉏ DŽ

6.3῵ 䗮䆃⊶⡍⥛ⱘ

⊶⡍⥛ 䆒 Ў3 ˈ῵ 䗮䖛㔥㒰䆒㕂CAN⊶⡍⥛ MAC ID ˈ ϡ ✻ ⷕ 䖯㸠䆒 DŽ㔥㒰䆒㕂 䗮䖛 Ҹ 䌘⑤㡖⚍0xEE 0xF0䆓䯂 ⦄ⱘDŽ

6.3.1㡖⚍MACID䆒㕂

䇈 ˖ Ā䖲㓁䇏ッ ā Ҹ Ё 䭓 Ў2Ͼ 㡖ˈ ㄀ϔϾ 㡖㸼⼎ ↉ⷕ 䆚˄Segflag =0x00˅ˈ㄀ѠϾ 㡖˄0$&,'˅Ў 㽕䆒 ⱘ㡖⚍ DŽ

䇈 ˖Ңキ ⱘ Ҹ ⊩ⱘˈϨℷ⹂ ⧚ ↩ˈ 䖨 ℷ ˗

䇈 ˖ Ңキ Ā䆒㕂MACIDā Ҹ ˈ 䆹 Ҹ 䴲⊩ˈ 䖨 䫭䇃 DŽ Ёҹ䫭䇃 㸼⼎ˈ ЁⱘERRID⫼Ѣ䇈 䫭䇃㉏ DŽ

z⼎՟

6.3.2㡖⚍⊶⡍⥛䆒㕂

䇈 ˖ Ā䖲㓁䇏ッ ā Ҹ Ё 䭓 Ў5Ͼ 㡖ˈ ㄀ϔϾ 㡖㸼⼎ ↉ⷕ 䆚˄Segflag =0x00˅ˈ㄀2~5Ͼ 㡖˄%$8'5$7(˅Ў 㽕䆒 ⱘ㡖⚍⊶⡍⥛ (⊼ ˖ ѢICAN῵ ˈ㄀2ǃ3ϸϾ 㡖 ˈ ҷ㸼 0ǃ 1 ˈ⊶⡍⥛䆒 ҹ 㗗䰘 )DŽ

䇈 ˖Ңキ ⱘ Ҹ ⊩ⱘˈϨℷ⹂ ⧚ ↩ˈ 䖨 ℷ ˗

䇈 ˖ Ңキ Ā䆒㕂MACIDā Ҹ ˈ 䆹 Ҹ 䴲⊩ˈ 䖨 䫭䇃 DŽ Ёҹ䫭䇃 㸼⼎ˈ ЁⱘERRID⫼Ѣ䇈 䫭䇃㉏ DŽ

z⼎՟

6.4 ԡ῵

Ā䆒 ԡā Ҹ ⫼Ѣ ԡ䆒 DŽ

䇈 ˖ Ā䆒 ԡā Ҹ Ё䌘⑤㡖⚍ ҹЎӏ ˈ 䭓 Ў2Ͼ 㡖ˈ ㄀ϔϾ 㡖㸼⼎ ↉ⷕ 䆚ˈ ㄀ѠϾ 㡖㸼⼎Ⳃ 㡖⚍IDDŽ

z⼎՟

相关主题