2018-04-23 08:15 AM
Hello everyone, I am trying to configure my CAN on my OLIMEXINO STM32 board :
https://www.olimex.com/Products/Duino/STM32/OLIMEXINO-STM32/
(with a STM32F103RBT6 �C), but it just won't work ...I'm using a PCAN USB to communicate between my PC and my board, but there is no data exchange between my board and my computer. The Pcan software is sending me a 'bus heavy' flag and I don't know why.
Here is my code :
int nb_trames = 4;
int ID[8] = {0x06, 0x11, 0x12, 0x13, 0x14,0x15,0x16,0x17}; Tab_TxMessages = malloc(nb_trames * sizeof(CanTxMsgTypeDef));...
while (1)
{int cpt = 0 ;
for (cpt = 0 ; cpt < nb_trames ; cpt++)
{ Tab_TxMessages[cpt].StdId = ID[cpt]; Tab_TxMessages[cpt].IDE = 0; Tab_TxMessages[cpt].RTR = 0; Tab_TxMessages[cpt].DLC = 8; Tab_TxMessages[cpt].Data[0] = cpt; Tab_TxMessages[cpt].Data[1] = cpt+1; Tab_TxMessages[cpt].Data[2] = cpt+2; Tab_TxMessages[cpt].Data[3] = cpt+3; Tab_TxMessages[cpt].Data[4] = cpt+4; Tab_TxMessages[cpt].Data[5] = cpt+5; Tab_TxMessages[cpt].Data[6] = cpt+6; Tab_TxMessages[cpt].Data[7] = cpt+7; HAL_CAN_Transmit(&hcan, HAL_MAX_DELAY); HAL_Delay(1); }}
(don't know how to properly format it though, if anyone can help...)
The issue is not coming from the 120 Ohm (I set the jumper correctly on the board). However it might come from the way I configure my CAN bus :
void MX_CAN_Init(void)
{hcan.Instance = CAN1;
hcan.Init.Prescaler = 4; hcan.Init.Mode = CAN_MODE_NORMAL; hcan.Init.SJW = CAN_SJW_1TQ; hcan.Init.BS1 = CAN_BS1_8TQ; hcan.Init.BS2 = CAN_BS2_8TQ; hcan.Init.TTCM = DISABLE; hcan.Init.ABOM = DISABLE; hcan.Init.AWUM = DISABLE; hcan.Init.NART = DISABLE; hcan.Init.RFLM = DISABLE; hcan.Init.TXFP = DISABLE; if (HAL_CAN_Init(&hcan) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }}
I have no idea how to correctly configure it, so if anyone dare to explain, that might help solve the issue..
Thank you for the help !
#pcan #can-interface #olimex #stm32f103rbt62018-04-25 08:01 AM
CANH / CANL swapped somewhere ?
Proper termination ?
Using PCAN stuff myself (PCAN Explorer), both mistakes used to produce such a result.
2018-04-25 08:06 AM
Termination is correctly set. CANH and CANL should also be ok according to the plans I've been given, I will swap them, just in case ...
I'm beggining to think it's a hardware issue, but can't find it ..
2018-04-25 08:11 AM
rebuild your project with the minimal functions (only sending a few CAN messages, nothing else) and post your binary here. I don't promise to find time to do it, but checking with o-scope can be helpful.
2018-04-25 08:11 AM
I changed the CANH and CANL, still not working
2018-04-25 09:21 AM
If you have more nodes, you can try to remove individual nodes, and check if anything changes.
Are the sampling points set correctly ?
2018-04-25 09:37 AM
I send it to you by PM, I also attach the project (the one the .bin is related to, so that you can make some little changes if you wich).
I actually found an old oscilloscope (analog ..) but i'm not exactly sure what am I supposed to look at and witness ...
Thank you for your help !
2018-04-25 09:41 AM
I just have CANH, CANL and GND
The sampling points ? I didn't have to set any sampling point (or I don't know I did ..)
2018-04-25 11:10 AM
ahem, did I say *only* CAN ??? Well I also need GPIO init ! Did you removed them because Iasked, or were they absent from your original project ?
Pay attention to the GPIO configuration to remap CAN1 to PB8/9, it is not the reset default, you need to write into AFIO->MAPR.
2018-04-25 06:29 PM
I used the CanDo unit for a week. everything worked brilliantly with the code I have already given you.
here are the sample points required by CanBus
2018-04-26 12:43 AM
Okay so ...
For some reason, it seems that the different Time Quantas my Peak USB likes to receive are different than what
GONZALEZ.Laurent
mentionned. I managed to find this out while searching a bit in the submenu of PcanView.So now it seems to be working ...
I feel a bit dumb though, but thank you everyone for the help anyway !