cancel
Showing results for 
Search instead for 
Did you mean: 

Can Bus, sending and receiving does not work

csminus
Associate II
Posted on June 15, 2015 at 21:25

ghhhhhhhhhhhhk

#lmgtfy #can-bus #stm32f207 #can-prescale-and-quanta
42 REPLIES 42
jpeacock
Associate III
Posted on June 15, 2015 at 22:22

When CAN doesn't work the first thing to do is check the ESR error status on both nodes (you need two, won't work for one).  Are both nodes configured the same way, and is the ESR the same?

  Jack Peacock
csminus
Associate II
Posted on June 16, 2015 at 08:33

In ESR REG i have nothing 0x00 

csminus
Associate II
Posted on June 16, 2015 at 13:42 When i debuging code i get

void
system_error_handle(eError error)
{
while
(
true
);
}

when i try to get some message from converter
jpeacock
Associate III
Posted on June 16, 2015 at 14:13

Do you have the peripheral clock enabled for CAN.  Not sure what the HAL library does, but you need to make sure the CAN clock is enabled in the RCC.  Registers that show zero are a common symptom of clock disabled.

  Jack Peacock

jpeacock
Associate III
Posted on June 16, 2015 at 14:24

Yes, the CAN clock is enabled but I don't see where theSYSCFG clock is set up, nor where the CAN pins are configured as AF.

For an F405 using PD0 and PD1 on CAN1:

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 
GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_CAN1); // CAN1 rx 
GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_CAN1); // CAN1 tx 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; // alternate function, CAN bus 
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // push-pull driver 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; // with pull-ups 
GPIO_Init(GPIOD, &GPIO_InitStructure); // enable CAN bus pins

Jack Peacock
csminus
Associate II
Posted on June 16, 2015 at 14:46

I was checked, CAN1 clock is on

csminus
Associate II
Posted on June 16, 2015 at 14:54

I was change pin mode to AF, but still dont works ;/ 

csminus
Associate II
Posted on June 16, 2015 at 15:08

hjghkgghkghk

Posted on June 16, 2015 at 16:55

May be you want to look at how other boards implement CAN, and how it's configured and working using the Standard Peripheral Library. I know I've posted a couple of F2 examples.

I'm not keen to dig through the register level configuration, or reinvent the wheel.

You need CAN transceivers, and TWO devices on the bus, ideally one configured as a listener. The transceivers need enabling, if they have such a pin. The bit/baud rate is predicated on the APB bus clock, the prescaler, and the bit timing settings.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..