本帖最后由 plabghhahacong1988 于 2015-9-17 14:23 编辑
我正在学习MPC5634,目前看芯片数据手册上介绍关于发送和接收LIN帧章节时,有一点疑问:
26.4.2.6 LIN transmit register (SCI_LTR)的结构:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|-------|-----------------------|-------------------------------|
|Parity | ID | LEN |
|-------|-----------------------|-------------------------------|
Reset| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|---|---|---|---|---------------|-------------------------------|
|CSM|CSE|CRC|TD | TO | DATA |
|---|---|---|---|---------------|-------------------------------|
Reset| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
26.5.6.3.1 Application controlled LIN TX frame generation (程序控制产生LIN Tx帧):
The first byte written to the SCI_LTR contains the Identifier and Identifier Parity fields. The second byte written defines the number of data bytes to be transmitted. The third write access defines the CRC and checksum generation. The TD bit has to set to 1 to invoke the TX frame generation. The TO field bits must be set to 0.
(写入SCI_LTR中的第一个字节包含id和奇偶标识段. 第二个写入的字节定义了发送数据的字节数. 第三次写操作定义了CRC和校验和的产生. TD位置1用于使能产生Tx帧. TO段必须设为0.)
如果我想设置ID = 0x35; LEN = 8; CSM = 1; CSE = 1; SCI_LTR寄存器的所有其他字段均为0.
此处不考虑TXRDY标识位的状态,该如何写SCI_LTR寄存器???
方式一:
ESCI_A.LTR.R = ((0x00000035<<24) | (0x00000008<<16) | (0x000000D0<<8));
方式二:
ESCI_A.LTR.R = 0x35; //1st byte Write ESCI_A.LTR.R = 0x05; //2st byte Write ESCI_A.LTR.R = 0xD0; //3st byte Write
请问,哪种写SCI_LTR寄存器的方式是正确的?
根据该寄存器的结构, 我认为第一种方式是正确的,但是根据芯片数据手册中的描述(26.5.6.3.1),感觉第二种方式是正确的。求大神指教,谢谢。
|