2013-04-11 07:03 AM
Hi,
I have a problem with the CAN keil example for mcbstm32 board. I use this example a lot with the remap for CAN so the pins are PB8 and PB9. That is theDefault configuration for the board. I tried to change the pins to original position with no remap (PA11 and PA12) to test the program with another board. So I go to CAN_STM32Fc and change the function to:/* 1. Enable CAN controller Clock */
RCC->APB1ENR |= (1 << 25);
/* Note: MCBSTM32 uses PB8 and PB9 for CAN */ /* 2. Setup CAN Tx and Rx pins */ // RCC->APB2ENR |= (1 << 0); // enable clock for Alternate Function
// AFIO->MAPR &= 0xFFFF9FFF; // reset CAN remap // AFIO->MAPR |= 0x00004000; // set CAN remap, use PB8, PB9 /* GPIOB clock enable */ // RCC->APB2ENR |= (1 << 3);
/* Configure CAN pin: RX PB.8 input push pull */ // GPIOB->CRH &= ~(0x0F<< 0);
// GPIOB->CRH |= (0x08<< 0);
/* Configure CAN pin: TX PB.9 alternate output push pull */ // GPIOB->CRH &= ~(0x0F<< 4);
// GPIOB->CRH |= (0x0B<< 4);
/* 2. Setup CAN Tx and Rx pins */ /* GPIOA clock enable */ RCC->APB2ENR |= (1 << 2);
/* Configure CAN pin: RX PA.11 input push pull */ GPIOA->CRH &= ~(0x0F<< 12);
GPIOA->CRH |= (0x08<< 12);
/* Configure CAN pin: TX PA.12 alternate output push pull */ GPIOA->CRH &= ~(0x0F<< 16);
GPIOA->CRH |= (0x0B<< 16);
/* 3. Setup IRQ vector for CAN interrupt */ /* not necessary */ /* 4. Enable CAN interrupt */ NVIC->IPR [4] |= 0x10000000; /* set priority lower than SVC */ NVIC->ISER[0] |= (1 << (USB_HP_CAN_TX_IRQChannel & 0x1F)); /* only FIFO 0 is used */ NVIC->IPR [5] |= 0x00000010; /* set priority lower than SVC */ NVIC->ISER[0] |= (1 << (USB_LP_CAN_RX0_IRQChannel & 0x1F)); return CAN_OK; It compile ok but after callingCAN_Start it stucks. The example is: C:\Keil\ARM\Boards\Keil\MCBSTM32\RL\CAN Any ideas? Thanks2013-04-11 10:38 AM
There is definitely an errata relating to USART1 CTS/RTS usage on PA11/12 and CAN1 interfering, but not sure it impacts CAN1. There is USB here too.
Does the port work in loop-back mode? Do you have transceivers requiring separate enablement?2013-04-11 10:54 AM
The loop back doesnt work and the tranceiver is SN65HVD230DR.
Where can I found this errata?2013-04-11 11:03 AM
Where can I found this errata?
Google STM32 Errata? It's on the website with the other product docs.http://www.st.com/st-web-ui/static/active/en/resource/technical/document/errata_sheet/CD00190234.pdf
2013-04-11 11:35 AM
Sorry I thought that was other errata.
Seems that its not my problem.In some specific cases, some potential weakness may exist between alternate functions mapped onto the same pin.
2.6.1 USART1_RTS and CAN_TX
Conditions
�? USART1 is clocked
�? CAN is not clocked
�? I/O port pin PA12 is configured as an alternate function output.STM32F10xxx silicon limitations Errata sheet
14/36 Doc ID 14574 Rev 11
Description
Even if CAN_TX is not used, this signal is set by default to 1 if I/O port pin PA12 is
configured as an alternate function output.
In this case USART1_RTS cannot be used.
I will probably just use the pins PB8 and PB9 for CAN.Thanks