Hi Ingo,
Well spotted on the major bug . I dont know how many times I checked that - obviously not looking properly - either I was misled by the bogus bus activity which convinced me the output pin was correctly configured , and / or was counting the bits from 1 rather than zero - whatever the reason - a rookie error.
SO, it is all working beautifully now ! I have eight bytes being sent and received, I have tested the code running on 2 x 18F248, 1 x 18F248 and 1 x 18F4580 and finally 2 x 18F4580. All running nicely.
Glad my understanding of the workings of the registers is validated but have a red face for not checking the TRISB setting.
Thanks Ingo - I would rather have a red face AND working code than the other way around.
CANCON.3=1, you are probably correct, this may not be necesary for the simple test program. see page 276 of the 4580 datsheet. bits 3,2 and 1 are called WIN bits, which set the particular transmit or receive buffer . Code 100 sets tx buffer0. I suspect I may have to set these bits depending on the tx buffer I wish to use, equally on the rx side I can use these to place data in a particular rx buffer. I think there may be a degree of automation to this process but have yet to play with the system to fully understand the workings.
Now I must stop calling it the CANT bus and give its real name CAN bus !
Got some work to do now, adding data transfer functionality and structuring code.
Thanks again - Once done, I will send you a copy of my working system if you PM me or provide an e mail address.
Bookmarks