Hej Christopher,
Din svenska är helt OK!
1) The MCP2515 has three transmit buffers (ie it's to these buffers you write the data to be sent out on the CAN bus). Each of these transmit buffers consists of 8 bytes. The first transmit buffer starts at $36 and ends at $3D. So the first byte of the first buffer is at address $36 and would be called TXB0D0 (Transmit Buffer 0 DataByte 0). The first byte of the second buffer would be at address $46 and would be called TXB1D0 (Transmit Buffer 1 DataByte 0) and so on.
You can't simply do TXB0D0 = $FF because, once again, the register is not in the PIC, you'll have to write to that register using either SHIFTOUT or the MSSP module like we discussed in one of the other threads. Ie, to load TXB0D0 with $FF you'd do
Code:
SHIFTOUT DataPin, ClkPin, MSBFirst, [2, $36, $FF] ' 2=Write Instruction, $36=adress of TXB0D0 regsiter, $FF=Data to be written to that register
Now, you can obviously create CONstants to the various registers and commands, like
Code:
WriteCmd CON 2
TXB0D0 CON $36
SHIFTOUT DataPin, ClkPin, MSBFirst, [WriteCmd, TXB0D0, $FF]
2) The register map on page 61 shows the address of all the registers in the device. TXBnSIDL and TXBnSIDH are Transmit Buffer Standard Identifier (whatever that is) register and since there are three Transmit buffers there are three TXNnSIDL and TXBnSIDH registers (again, n would be 0,1 or 2 for the three individual registers "coupled" to each transmit buffer.
So, looking at the table on page 61, you can see that the four high order bits of the address are in the columns and the four low order bits are in the rows. For TXB0SIDL you'll get 0011 for the high order bits and 0010 for the low order bits. Combing these give you %00110010 which is the same as $32 - which, if you look at the description for the TXBnSIDL register (page 20) matches what they say IS the address of TXB0SIDL.
So, to write the value $12 to TXB0SIDL you'd do
Code:
SHIFTOUT DataPin, ClkPin, MSBFirst, [2, $32, $12] '2=WriteInstruction, $32= Adress of register, $12=Data to write.
In the register map all register which are allowed to be manipulated by the BitModify instruction are shaded. The TXBnSIDL registers are not shaded and can not be modified using the BitModify instruction.
/Henrik.
Bookmarks