Problem getting CAN to work on STM32F767

Working libraries, libraries being ported and related hardware
0v3rcl0ck3d
Posts: 6
Joined: Wed Apr 27, 2022 6:42 pm

Problem getting CAN to work on STM32F767

Post by 0v3rcl0ck3d »

Hi,
hope this is the right spot to post this problem. I am trying to get CAN working on a custom board with a STM32F767. However, I am completely stuck and there is no progress anymore with try and error. Since the code of the project is not open, I am not able to share the whole project but I am able to share the needed code snippets.

I already studied the reference manual of this processor but I am not experienced with low level coding.

I hope this description is useful for you. I try to implement CAN like it is documented here:
https://github.com/stm32duino/Arduino_C ... _hal_can.c

I used this as help:
viewtopic.php?f=39&t=313&start=10

(I also tried to implement CAN using the following but was not able to get it working (first time using low level code and first time using CAN):
https://github.com/nopnop2002/Arduino-STM32-CAN
but as far as I understand, this has nothing to do with the implementation above.)

A MCP2551 is placed there (snipped from board layout)
mcp2551_on_board.png
mcp2551_on_board.png (64.68 KiB) Viewed 6924 times
:

Snippets from variant.h of the custom board:

Code: Select all

#define HAL_CAN_MODULE_ENABLED
Snippets from PeriphalPins.c of custom board. RX is on PB12, TX on PB13.

Code: Select all

WEAK const PinMap PinMap_CAN_RD[] = {
    //  {PA_8,  CAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_CAN3)},
    //  {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
    // {PB_3,  CAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_CAN3)}, // D23
    // {PB_5,  CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // D22 (D11)
    // {PB_8,  CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // D15 (A5)
    {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // D19
    // {PD_0,  CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // D67 CAN_RX
    {NC, NP, 0}};
#endif

#ifdef HAL_CAN_MODULE_ENABLED
WEAK const PinMap PinMap_CAN_TD[] = {
    //  {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
    // {PA_15, CAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_CAN3)}, // D20
    // {PB_4,  CAN3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF11_CAN3)}, // D25
    // {PB_6,  CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // D26
    // {PB_9,  CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // D14 (A4)
    {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, // D18
    // {PD_1,  CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // D66 CAN_TX
    {NC, NP, 0}};
#endif
At the moment, I will just share the necessary code to not blow up this post. I implemented the following:

Code: Select all

int CANSetup(void)
{
  CAN_FilterTypeDef sFilterConfig = {0} ;

  hCAN.State = HAL_CAN_STATE_RESET ;
  can_rx_head = can_rx_tail = can_rx_lost = 0;

  hCAN.Instance = CAN2;
  hCAN.Init.Prescaler = 16;    // we need 125 000 b/s
  hCAN.Init.Mode = CAN_MODE_NORMAL;
  hCAN.Init.SyncJumpWidth = CAN_SJW_4TQ;
  hCAN.Init.TimeSeg1 = CAN_BS1_12TQ;
  hCAN.Init.TimeSeg2 = CAN_BS2_5TQ;
  hCAN.Init.TimeTriggeredMode = DISABLE;
  hCAN.Init.AutoBusOff = DISABLE;
  hCAN.Init.AutoWakeUp = DISABLE;
  hCAN.Init.AutoRetransmission = ENABLE;
  hCAN.Init.ReceiveFifoLocked = DISABLE;
  hCAN.Init.TransmitFifoPriority = DISABLE;
    
  if (HAL_CAN_Init(&hCAN) != HAL_OK)
  {
    return 1;
  }

  sFilterConfig.FilterFIFOAssignment=CAN_FILTER_FIFO0; //set fifo assignment
  sFilterConfig.FilterIdHigh = 0 ;
  sFilterConfig.FilterIdLow = 0 ;
  sFilterConfig.FilterMaskIdHigh = 0;
  sFilterConfig.FilterMaskIdLow = 0;
  sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; //set filter scale
  sFilterConfig.FilterActivation = ENABLE;
  sFilterConfig.FilterBank = 0 ;
  sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK ;
    
  HAL_CAN_ConfigFilter(&hCAN, &sFilterConfig); //configure CAN filter

  //HAL_CAN_ActivateNotification(&hCAN, CAN_IT_RX_FIFO0_MSG_PENDING); //enable interrupts

  if (HAL_CAN_Start(&hCAN) != HAL_OK)
  {
    return 2;
  }
  return 0;
}

void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0} ;

  __HAL_RCC_CAN1_CLK_ENABLE();
  //__HAL_RCC_CAN2_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();
  
  // Configuration des pins PB8 (RX) et PB9 (TX)
  GPIO_InitStruct.Pin = GPIO_PIN_13;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  GPIO_InitStruct.Pin = GPIO_PIN_12;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

  //__HAL_AFIO_REMAP_CAN1_2() ;

  //HAL_NVIC_SetPriority(USB_LP_CAN1_RX0_IRQn, 0 , 0) ;
  //HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn) ;
}


When calling

Code: Select all

int CANSetup(void)
in my setup function, the return code is 1.

I would really appreciate some help because I am totally stuck. If you need some further informations, just let me know.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Problem getting CAN to work on STM32F767

Post by fpiSTM »

As a first guess use extern "C" for all functions.
darkspr1te
Posts: 26
Joined: Tue Jan 07, 2020 4:22 pm

Re: Problem getting CAN to work on STM32F767

Post by darkspr1te »

0v3rcl0ck3d wrote: Wed May 04, 2022 7:18 pm Hi,
hope this is the right spot to post this problem. I am trying to get CAN working on a custom board with a STM32F767. However, I am completely stuck and there is no progress anymore with try and error. Since the code of the project is not open, I am not able to share the whole project but I am able to share the needed code snippets.

When calling

Code: Select all

int CANSetup(void)
in my setup function, the return code is 1.

I would really appreciate some help because I am totally stuck. If you need some further informations, just let me know.
I would first write some test code to blink the PB12/PB13 pins without any can involved, then add the can modules and code and repeat, this is to confirm is the can code is interfering with normal gpio operation which in this case is desired, as when we activate the CAN system we should not be able to toggle the gpio, a little note that you need to pick the correct board layout in your IDE as some boards have hidden defines that will force other pins to be CAN or force other ALT functions(see code snippet below) , I hack and re-firmware a LOT of stm32 boards and while arduino system is simple to use it's a nightmare when it comes to custom boards and have since switched to a platformio+stm32cube /cmsis backend (instead of arduino on top of stm32cube)

Anyway, i dug out some old canbus code i had for another project and saw some items of note

in my can setup routines,

Code: Select all

void CANSetup(void)
{
{
CAN_STATUS Stat ;

  Serial.end();//Ensure USB has given up PA11/PA12, required only in arduino ENV, not required for stm32cube or cmsis 
  Serial1.println("About to setup CAN");
// Initialize CAN module
  Stat = canBus.map(CAN_GPIO_PA11_PA12);       // This setting is already wired in the OM127
    if (Stat != CAN_OK){
       Serial1.println("ERROR map can port");
       Serial1.println(Stat,DEC);
    }
the above was required what ever pins I choose for CANBUS , i had to ensure that no serial driver/USB was loaded and force the mapping of desired pins,

next was configure the CANBUS itself,

Code: Select all

/*
* CAN_SPEED_33,
  CAN_SPEED_95,
  CAN_SPEED_125,
  CAN_SPEED_250,
  CAN_SPEED_500,
  CAN_SPEED_1000,
   */

  Stat = canBus.begin(CAN_SPEED_500, CAN_MODE_NORMAL);    // Other speeds go from 125 kbps to 1000 kbps. CAN allows even more choices.
  if (Stat != CAN_OK){
       u8g2.print("ERROR CAN BUS Stuck");
       u8g2.print(Stat,DEC);
  }
The above section confirms the canbus type i need (ack or no ack, sniff or no sniffing, speed)
and final i set my filters and parameters

Code: Select all

 canBus.filter(0, DEFAULT_MASK, 0,0);                // listen for OBD req, ack simple 
  canBus.set_irq_mode();              // Use irq mode (recommended), so the handling of incoming messages
                                      // will be performed at ease in a task or in the loop. The software fifo is 16 cells long, 
                                      // allowing at least 15 ms before processing the fifo is needed at 125 kbps                                  
  Stat = canBus.status();
  if (Stat != CAN_OK)
  {
       u8g2.print("ERROR CAN system -");
       u8g2.print(Stat,DEC);
  }
  else
   u8g2.print("CAN Init Success ");

I found that not following the above model would give my CANBUS issues, also dont forget your termination resistors !, depending on how you bring up the canbus interface would effect how it see's the canbus lines when you Init the interface, if you dont have it in dumb mode it will try and use the bus and fail, returning a init error.
the above code is valid for the official canbus arduino library , depending on your chosen IDE you might also have access to the registers when realtime debugging, it's always worth confirming the values against the TRM and also look for any supplimental manuals or errata's + bug notices, i remember one of the 72x models had a canbus bug in that you HAD to bring up the interface without ack enabled and no filters applied as the canbus PHY would blip the physical bus and the work around was to hold the MCP can chip in power down mode first then enable the output after init.
Also even though you may be using different pins you still need to ensure there no auto arduino device starting up on those pins, even though I was not using serial0 and had no startup code for it the arduino env still added irq and such breaking my later code.
this was the reason for the switch from arduino to stm32cube/cmsis/opencm3 and platformio ,
it was platformio that helped me discover the usb serial/can issue and platformio allows line by line debugging including the hidden setup parts you dont see in the arduino IDE. for example the setup of the vector table (important if you intend to use can tx/rx irq's)


well , i hope this is of help

darkspr1te
darkspr1te
Posts: 26
Joined: Tue Jan 07, 2020 4:22 pm

Re: Problem getting CAN to work on STM32F767

Post by darkspr1te »

If you are not using arduino and are using stm32 cube then this code should init without error,
main.c

Code: Select all

uint8_t ubKeyNumber = 0x0;
CAN_HandleTypeDef     CanHandle;
CAN_TxHeaderTypeDef   TxHeader;
CAN_RxHeaderTypeDef   RxHeader;
uint8_t               TxData[8];
uint8_t               RxData[8];
uint32_t              TxMailbox;


static void CAN_Config(void)
{
  CAN_FilterTypeDef  sFilterConfig;

  /*##-1- Configure the CAN peripheral #######################################*/
  CanHandle.Instance = CANx;

  CanHandle.Init.TimeTriggeredMode = DISABLE;
  CanHandle.Init.AutoBusOff = DISABLE;
  CanHandle.Init.AutoWakeUp = DISABLE;
  CanHandle.Init.AutoRetransmission = ENABLE;
  CanHandle.Init.ReceiveFifoLocked = DISABLE;
  CanHandle.Init.TransmitFifoPriority = DISABLE;
  CanHandle.Init.Mode = CAN_MODE_NORMAL;
  CanHandle.Init.SyncJumpWidth = CAN_SJW_1TQ;
  CanHandle.Init.TimeSeg1 = CAN_BS1_4TQ;
  CanHandle.Init.TimeSeg2 = CAN_BS2_2TQ;
  CanHandle.Init.Prescaler = 6;

  if (HAL_CAN_Init(&CanHandle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }

  /*##-2- Configure the CAN Filter ###########################################*/
  sFilterConfig.FilterBank = 0;
  sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
  sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
  sFilterConfig.FilterIdHigh = 0x0000;
  sFilterConfig.FilterIdLow = 0x0000;
  sFilterConfig.FilterMaskIdHigh = 0x0000;
  sFilterConfig.FilterMaskIdLow = 0x0000;
  sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
  sFilterConfig.FilterActivation = ENABLE;
  sFilterConfig.SlaveStartFilterBank = 14;

  if (HAL_CAN_ConfigFilter(&CanHandle, &sFilterConfig) != HAL_OK)
  {
    /* Filter configuration Error */
    Error_Handler();
  }

  /*##-3- Start the CAN peripheral ###########################################*/
  if (HAL_CAN_Start(&CanHandle) != HAL_OK)
  {
    /* Start Error */
    Error_Handler();
  }

  /*##-4- Activate CAN RX notification #######################################*/
  if (HAL_CAN_ActivateNotification(&CanHandle, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
  {
    /* Notification Error */
    Error_Handler();
  }

  /*##-5- Configure Transmission process #####################################*/
  TxHeader.StdId = 0x321;
  TxHeader.ExtId = 0x01;
  TxHeader.RTR = CAN_RTR_DATA;
  TxHeader.IDE = CAN_ID_STD;
  TxHeader.DLC = 2;
  TxHeader.TransmitGlobalTime = DISABLE;
}

/**
  * @brief  Rx Fifo 0 message pending callback
  * @param  hcan: pointer to a CAN_HandleTypeDef structure that contains
  *         the configuration information for the specified CAN.
  * @retval None
  */
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
  /* Get RX message */
  if (HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader, RxData) != HAL_OK)
  {
    /* Reception Error */
    Error_Handler();
  }

  /* Display LEDx */
  if ((RxHeader.StdId == 0x321) && (RxHeader.IDE == CAN_ID_STD) && (RxHeader.DLC == 2))
  {
//    LED_Display(RxData[0]);
    ubKeyNumber = RxData[0];
  }
}

and in stmf32f7xx_it.c

Code: Select all

extern CAN_HandleTypeDef    CanHandle;
void CANx_RX_IRQHandler(void)
{
  HAL_CAN_IRQHandler(&CanHandle);
}

stm32f7xx_hal_msp.c

Code: Select all


void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan)
{
  GPIO_InitTypeDef   GPIO_InitStruct;

  /*##-1- Enable peripherals and GPIO Clocks #################################*/
  /* CAN1 Periph clock enable */
  CANx_CLK_ENABLE();
  /* Enable GPIO clock ****************************************/
  CANx_GPIO_CLK_ENABLE();

  /*##-2- Configure peripheral GPIO ##########################################*/
  /* CAN1 TX GPIO pin configuration */
  GPIO_InitStruct.Pin = CANx_TX_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Alternate =  CANx_TX_AF;

  HAL_GPIO_Init(CANx_TX_GPIO_PORT, &GPIO_InitStruct);

  /* CAN1 RX GPIO pin configuration */
  GPIO_InitStruct.Pin = CANx_RX_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Alternate =  CANx_RX_AF;

  HAL_GPIO_Init(CANx_RX_GPIO_PORT, &GPIO_InitStruct);

  /*##-3- Configure the NVIC #################################################*/
  /* NVIC configuration for CAN1 Reception complete interrupt */
  HAL_NVIC_SetPriority(CANx_RX_IRQn, 1, 0);
  HAL_NVIC_EnableIRQ(CANx_RX_IRQn);
}

/**
  * @brief CAN MSP De-Initialization
  *        This function frees the hardware resources used in this example:
  *          - Disable the Peripheral's clock
  *          - Revert GPIO to their default state
  * @param hcan: CAN handle pointer
  * @retval None
  */
void HAL_CAN_MspDeInit(CAN_HandleTypeDef *hcan)
{
  /*##-1- Reset peripherals ##################################################*/
  CANx_FORCE_RESET();
  CANx_RELEASE_RESET();

  /*##-2- Disable peripherals and GPIO Clocks ################################*/
  /* De-initialize the CAN1 TX GPIO pin */
  HAL_GPIO_DeInit(CANx_TX_GPIO_PORT, CANx_TX_PIN);
  /* De-initialize the CAN1 RX GPIO pin */
  HAL_GPIO_DeInit(CANx_RX_GPIO_PORT, CANx_RX_PIN);

  /*##-4- Disable the NVIC for CAN reception #################################*/
  HAL_NVIC_DisableIRQ(CANx_RX_IRQn);
}

again, hope that helps

darkspr1te
darkspr1te
Posts: 26
Joined: Tue Jan 07, 2020 4:22 pm

Re: Problem getting CAN to work on STM32F767

Post by darkspr1te »

one final note, pay attention to what written in this message
viewtopic.php?p=2153#p2153
So I conclude that the bootstrap loader, when it jumps to the application program, does not shut off the USB, and this must have been done in the core
you may also have this issue depending what boot loader you use or not, it might not be USB specific , it could be another item the bootloader initializes. if you are not using a bootloader and direct swd/jtag then this should not apply.

darkspr1te
0v3rcl0ck3d
Posts: 6
Joined: Wed Apr 27, 2022 6:42 pm

Re: Problem getting CAN to work on STM32F767

Post by 0v3rcl0ck3d »

fpiSTM wrote: Wed May 04, 2022 7:28 pm As a first guess use extern "C" for all functions.
Since there are no linker errors and the code compiles, I don't think this will make any difference. However, I tried without any success.
0v3rcl0ck3d
Posts: 6
Joined: Wed Apr 27, 2022 6:42 pm

Re: Problem getting CAN to work on STM32F767

Post by 0v3rcl0ck3d »

darkspr1te wrote: Thu May 05, 2022 7:30 am
0v3rcl0ck3d wrote: Wed May 04, 2022 7:18 pm Hi,
hope this is the right spot to post this problem. I am trying to get CAN working on a custom board with a STM32F767. However, I am completely stuck and there is no progress anymore with try and error. Since the code of the project is not open, I am not able to share the whole project but I am able to share the needed code snippets.

When calling

Code: Select all

int CANSetup(void)
in my setup function, the return code is 1.

I would really appreciate some help because I am totally stuck. If you need some further informations, just let me know.
I would first write some test code to blink the PB12/PB13 pins without any can involved, then add the can modules and code and repeat, this is to confirm is the can code is interfering with normal gpio operation which in this case is desired, as when we activate the CAN system we should not be able to toggle the gpio, a little note that you need to pick the correct board layout in your IDE as some boards have hidden defines that will force other pins to be CAN or force other ALT functions(see code snippet below) , I hack and re-firmware a LOT of stm32 boards and while arduino system is simple to use it's a nightmare when it comes to custom boards and have since switched to a platformio+stm32cube /cmsis backend (instead of arduino on top of stm32cube)

Anyway, i dug out some old canbus code i had for another project and saw some items of note

in my can setup routines,

Code: Select all

void CANSetup(void)
{
{
CAN_STATUS Stat ;

  Serial.end();//Ensure USB has given up PA11/PA12, required only in arduino ENV, not required for stm32cube or cmsis 
  Serial1.println("About to setup CAN");
// Initialize CAN module
  Stat = canBus.map(CAN_GPIO_PA11_PA12);       // This setting is already wired in the OM127
    if (Stat != CAN_OK){
       Serial1.println("ERROR map can port");
       Serial1.println(Stat,DEC);
    }
the above was required what ever pins I choose for CANBUS , i had to ensure that no serial driver/USB was loaded and force the mapping of desired pins,

next was configure the CANBUS itself,

Code: Select all

/*
* CAN_SPEED_33,
  CAN_SPEED_95,
  CAN_SPEED_125,
  CAN_SPEED_250,
  CAN_SPEED_500,
  CAN_SPEED_1000,
   */

  Stat = canBus.begin(CAN_SPEED_500, CAN_MODE_NORMAL);    // Other speeds go from 125 kbps to 1000 kbps. CAN allows even more choices.
  if (Stat != CAN_OK){
       u8g2.print("ERROR CAN BUS Stuck");
       u8g2.print(Stat,DEC);
  }
The above section confirms the canbus type i need (ack or no ack, sniff or no sniffing, speed)
and final i set my filters and parameters

Code: Select all

 canBus.filter(0, DEFAULT_MASK, 0,0);                // listen for OBD req, ack simple 
  canBus.set_irq_mode();              // Use irq mode (recommended), so the handling of incoming messages
                                      // will be performed at ease in a task or in the loop. The software fifo is 16 cells long, 
                                      // allowing at least 15 ms before processing the fifo is needed at 125 kbps                                  
  Stat = canBus.status();
  if (Stat != CAN_OK)
  {
       u8g2.print("ERROR CAN system -");
       u8g2.print(Stat,DEC);
  }
  else
   u8g2.print("CAN Init Success ");

I found that not following the above model would give my CANBUS issues, also dont forget your termination resistors !, depending on how you bring up the canbus interface would effect how it see's the canbus lines when you Init the interface, if you dont have it in dumb mode it will try and use the bus and fail, returning a init error.
the above code is valid for the official canbus arduino library , depending on your chosen IDE you might also have access to the registers when realtime debugging, it's always worth confirming the values against the TRM and also look for any supplimental manuals or errata's + bug notices, i remember one of the 72x models had a canbus bug in that you HAD to bring up the interface without ack enabled and no filters applied as the canbus PHY would blip the physical bus and the work around was to hold the MCP can chip in power down mode first then enable the output after init.
Also even though you may be using different pins you still need to ensure there no auto arduino device starting up on those pins, even though I was not using serial0 and had no startup code for it the arduino env still added irq and such breaking my later code.
this was the reason for the switch from arduino to stm32cube/cmsis/opencm3 and platformio ,
it was platformio that helped me discover the usb serial/can issue and platformio allows line by line debugging including the hidden setup parts you dont see in the arduino IDE. for example the setup of the vector table (important if you intend to use can tx/rx irq's)


well , i hope this is of help

darkspr1te
This is a big amount of things to check and test, thanks.It will take some time. First I have to find PB12 and PB13 for measure the blinking.

However, this seems to be another interface as described in https://github.com/stm32duino/Arduino_C ... _hal_can.c. Where can I find some documentation of this functions?

I think it will take too much time to move this project to another IDE.

Would it help to post the whole arduino board definition for this board?
0v3rcl0ck3d
Posts: 6
Joined: Wed Apr 27, 2022 6:42 pm

Re: Problem getting CAN to work on STM32F767

Post by 0v3rcl0ck3d »

darkspr1te wrote: Thu May 05, 2022 7:50 am one final note, pay attention to what written in this message
viewtopic.php?p=2153#p2153
So I conclude that the bootstrap loader, when it jumps to the application program, does not shut off the USB, and this must have been done in the core
you may also have this issue depending what boot loader you use or not, it might not be USB specific , it could be another item the bootloader initializes. if you are not using a bootloader and direct swd/jtag then this should not apply.

darkspr1te
I am using STM32CubeProgrammer (SWD).
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Problem getting CAN to work on STM32F767

Post by fpiSTM »

0v3rcl0ck3d wrote: Thu May 05, 2022 2:15 pm
fpiSTM wrote: Wed May 04, 2022 7:28 pm As a first guess use extern "C" for all functions.
Since there are no linker errors and the code compiles, I don't think this will make any difference. However, I tried without any success.
This is normal like some function are weak you will have no linker error but for those you redefine (like hal_can_msp_init) are defined in a cpp file and so are decorated by the compiler and will never get called instead the default weak will be called....
darkspr1te
Posts: 26
Joined: Tue Jan 07, 2020 4:22 pm

Re: Problem getting CAN to work on STM32F767

Post by darkspr1te »

0v3rcl0ck3d wrote: Thu May 05, 2022 2:25 pm
This is a big amount of things to check and test, thanks.It will take some time. First I have to find PB12 and PB13 for measure the blinking.

However, this seems to be another interface as described in https://github.com/stm32duino/Arduino_C ... _hal_can.c. Where can I find some documentation of this functions?

I think it will take too much time to move this project to another IDE.

Would it help to post the whole arduino board definition for this board?
The test and checking of PB12/13 is a test i often do when having issues(with any pins), I will often write pure test code just to see if that fixes any issues and the incorporate my fixes into the final project, You may have to do this often for a few reason,
1, you are using stm32cube which often has bugs and is out of your control (unless you settle on a githubbed version that you choose to update)
2, stm32cube often has different ways of doing the same things, one works and one does not , often traced to defines required on the command line



darkspr1te
Post Reply

Return to “Libraries & Hardware”