Jag är trött.....snälla hjälp mig!
It's 1am here so hopefully this post is clear enough and someone can help me! I've been adjusting settings and trying new things and it still doesn't work. Here is what it boils down to. This is a picture of the working code from Microchip (if I knew C I'd be done already).
Channel 1 (Yellow) SDO from 18F4550
Channel 2 (Blue) CS from 18F4550
Channel 3 (Purple) TXCAN from MCP2515
Channel 4 (Green) CLK from 18F4550?
This is what I'm looking to achieve.
This is what my code looks like:
![]()
At least it's not that much different and I'm in the ballpark. What I can see is the signals are similar but way more compressed. It seems like a timing issue but I really don't know.
I adjusted the oscilloscope to the same seconds/division as the Microchip example and it's very compressed. It looks like this:
I tried adjusting the HSPLL to HS and that seemed to make things a little better but didn't do much as far as a working program. The clock still looks strange when I compare it with the Microchip code.
The other things I see wrong:
1. The code I'm using is sending one data packet, along with SIDH and SIDL. I setup Microchip's program to do the same thing. I can't figure out why but my code is sending a lot more than a few bytes of data. In fact, it overloads the demo program that Microchip supplies and shuts it down.
2. Microchip's code sends the CAN data after the CS line goes high. For some reason, my program sends it halfway through the data transfer and my SDO line and the CAN output line are sending data at the same time. I did it once (send data after the CS line went high) but I can't remember what I did.
3. I'm confused with the CKE/CKP bits and not sure what I need to set them as. I see this "mode 0,0" advertised in the MCP2515 datasheet but it literally means nothing to me and I'm sure it's pretty important.
4. Did I properly set my BAUDCON?
Bookmarks