12 years, 8 months ago.

How can I choose different uController pins for CAN bus I/O than the pins the mbed libraries use?

I've tested my application on an mbed and all works fine. Now I need to port it to my target hardware. My application uses the CAN 2 interface. This connection is setup with:

CAN can2(p30, p29);

On the mbed, pins 30 & 29 correspond to pins 81 & 80 of the uController. On my target hardware, however, the CAN2 interface needs to be connected to pins 66 & 65 of the uController. Is there a way to specify these alternate CAN2 IO pins? Has anyone ever done this?

2 Answers

12 years, 7 months ago.

You need to change the configuration in the Pin Function Select Registers (PINSELx). Not done it myself, but if your not using the actual mbed board, then you shouldn't have any problems reconfiguring.

something like

LPC_PINCON->PINSEL0 &= FFFFF0FF;

to clear bits 8, 9, 10 and 11 from PINSEL0 to set pins 80 and 81 to GPIO, then

LPC_PINCON->PINSEL4 &= FFF5FFFF; LPC_PINCON->PINSEL4 |= 000A0000;

to clear bits 16 and 18 and set bits 17 and 19 of PINSEL4 to configure as TXD2 and RXD2.

Accepted Answer

Thanks, that works well

posted by Jim Thor 25 Jan 2013
12 years, 7 months ago.

Find out to which LPC1768 pins those pins on the uController correspond (so for example port 2, pin 15), then in your code use CAN can2(P2_15, P2_16). (Those pin names are completely random).

Now I assume on the mbed those pins arent used, but at least for SPI the mbed library had no issues with using SPI pins which normally arent used by the mbed. If that doesnt work you got to try what Chris wrote.

Edit: Well that question is kinda old.