STM32F103 CAN

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
andresv
Posts: 15
Joined: Tue Nov 29, 2016 11:09 am
Been thanked: 5 times

STM32F103 CAN

Postby andresv » Mon Mar 06, 2017 1:03 pm

Hi,

I am trying to get CAN working with STM32F103 (Maple Mini clone). I verified with logic analyzer that physical data is correct after tranceiver.
My question is how to properly setup F103 pins for CAN. I am more familiar with F4 series where there is nice function for that: palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(9)) etc.

However it is done differently with F1 series and I am not completely sure how.
Currently I did this:

Code: Select all

           
// setup CAN pins
palSetPadMode(GPIOA, 11, PAL_MODE_STM32_ALTERNATE_OPENDRAIN); // RX
palSetPadMode(GPIOA, 12, PAL_MODE_STM32_ALTERNATE_PUSHPULL);  // TX


But I guess there is something needed to actually define those pins as CAN pins. NB I desoldered all USB related components from this board because originally those pins were shared with USB.

NB: for CAN driver I am using example from testhal/STM32/STMF1xx/CAN.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32F103 CAN

Postby Giovanni » Mon Mar 06, 2017 1:32 pm

Hi,

I think it is alternate mode, the details should be in the data sheet.

Giovanni

pcat
Posts: 5
Joined: Wed Sep 07, 2016 9:14 am

Re: STM32F103 CAN

Postby pcat » Thu May 11, 2017 9:37 am

Hi hopefully you have resolved your issue, but just in case I use :-

Board.h file
#define VAL_GPIODCRL (PIN_INPUT(0) | /* CAN RX. */ \
PIN_ALTERNATE_PP_50(1) | /* CAN TX. */ \

My board also required a remap from the Default pins as below

Init section in Main.c
AFIO->MAPR |= AFIO_MAPR_CAN_REMAP_REMAP3; /* Map CAN to PD0/PD1 */

On a 100 pin F103


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 22 guests