Page 1 of 1

STM32F103 CAN

Posted: Mon Mar 06, 2017 1:03 pm
by andresv
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.

Re: STM32F103 CAN

Posted: Mon Mar 06, 2017 1:32 pm
by Giovanni
Hi,

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

Giovanni

Re: STM32F103 CAN

Posted: Thu May 11, 2017 9:37 am
by pcat
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