Well, I've connected the board to a PC using a CANUSB adapter listening at 100Kbps, but does not receive anything. This is the code (18F258+MCP2510 20Mhz):
What's wrong?Code:define OSC 20 TRISB = %000001000 'portb.2 output, portb.3 input CANCON = $80 'configuration mode 'Set Data Rate based on 20Mhz to get 100 kbs: BRGCON1 = $04 BRGCON2 = $BF BRGCON3 = $02 CIOCON = $10 TXB0SIDH = $0 TXB0SIDL = $1 CANCON = $0 'normal mode ' ' Program ' Main: TXB0DLC = 8 TXB0D0 = 65 TXB0D1 = 66 TXB0D2 = 67 TXB0D3 = 68 TXB0D4 = 69 TXB0D5 = 70 TXB0D6 = 71 TXB0D7 = 72 TXB0CON = 8 pause 1000 Goto main End
Last edited by zx81sp; - 21st February 2010 at 18:27.
Your program looks OK at first glance altough I didn't verify the BRG values.
What puzzles me is: do you really use an PIC18F258 in combination with an MCP2510?
Or do you use the PIC18F258 with the MCP2551 CAN transceiver as mentioned earlier?
The MCP2551 has a standby pin - how is it controlled?
It must be tied low for operation!
Check this and we can do further examination on the code.
Are you sure you have set up and connected your CAN-USB adaptor correctly?
A scope could show you if there is any activity on the bus.
I've got the BRG values using Microchip Can Bit Timing Calculator (from www.intrepidcs.com), it claims to be compatible with MCP2510, I think that the values are same for my MCP2551, also tried with the default values that the calculator shows (03/BF/07) but anyway nothing changes.
Sorry, the right combo is 18F258+MCP2551.What puzzles me is: do you really use an PIC18F258 in combination with an MCP2510?
Or do you use the PIC18F258 with the MCP2551 CAN transceiver as mentioned earlier?
RS Pin is connected to GNDThe MCP2551 has a standby pin - how is it controlled?
It must be tied low for operation!
When I connect the CANUSB to the CAN network I can see the traffic, so I think that the problem it's not there. When I connect the adapter directly to the board I can't see activity, if the PBP code is right I must receive a command every second.Check this and we can do further examination on the code.
Are you sure you have set up and connected your CAN-USB adaptor correctly?
Thanks for your help!
Last edited by zx81sp; - 21st February 2010 at 22:36.
Another point to check just came into my mind:
The PIC you are using has internal PLL - did you check its configuration?
Hmm...
I got $03 $BF $07 for 20MHz and 100kbps from the calculator.
Furthermore, your CIOCON configuration differs from the one I suggested, try setting it to $20.
Another idea: I am not sure whether you have to set the DLC register in config mode or if normal mode is possible..
Last edited by inse; - 22nd February 2010 at 23:18.
Bookmarks