cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F722ZE CAN BUS implementation

David Pekin
Senior
Posted on January 09, 2018 at 01:43

I've recently brought up the CAN bus on a STM32F303 and I'm currently working on bringing it up on the F722ZE. I looked at the docs and the samples from the STM32756G_EVAL board. I was happy to see that the configuration looked pretty similar to the F303 board in that the CAN TX and RX pins are the same, i.e. PA11 and PA12 with AF9 configuration. The clocks are different but I'm using the clock configuration from the F722ZE I2C sample code so the clocks are working since the I2C is working. Unfortunately, when I try to do a CAN transmit, I get nothing on the CAN TX pin. It remains high. Likewise, when I send a packet to the F722ZE I never get a CAN receive complete callback. I'm missing something here.

Any thoughts on how the F722 needs to be programmed differently than the F303 board?

Thanks,

Dave

Note: this post was migrated and contained many threaded conversations, some content may be missing.
9 REPLIES 9
David Pekin
Senior
Posted on January 09, 2018 at 20:08

I'm still trying to get action on the PA11/PA12 when I call HAL_CAN_Transmit()...  The function returns a HAL_OK response but nothing on the TX pin.  Likewise no RX interrupt when I send a packet from the USB CAN dongle.  I do see the correct signal on the RX pin.  The mask is set up correctly to receive the packet.

The CAN configuration (main.h, CAN_Config(), and msp functions) are taken directly out of the STM32F769I_eval  Networking CAN sample program.   The TX/RX pins are PA12 and PA11 respectively.  Those are brought out to the CN12 pins 14 and 16 on the Nucleo-144 board.  

I've already brought CAN up on the F303 Nucleo 64 board so I've got a decent idea of how this should work but I'm at a loss somewhere.   Anybody with any suggestions on what I'm missing?

Thanks,

Posted on January 09, 2018 at 21:35

Have you altered the SB (solder bridges) to allow for this functionality on PA11/PA12?

I'd need to see the code you're actually building rather than try to recreate it by walking in your footprints.

Make sure you are enabling the right clocks, and doing so before configuring the peripherals reliant on those clocks.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 09, 2018 at 21:57

I have not done anything with solder bridges...  I will look into that.   Thanks.

Posted on January 09, 2018 at 22:05

The manual indicates that PA11/12 are used as D+ and D- on the USB CN13 which is the plug I use for the ST-Link.  I have to remove the solder bridges to use PA11/12 as GPIO.   Do you know if the USB ST-link will still work if those bridges are removed?

Posted on January 09, 2018 at 22:39

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6uK&d=%2Fa%2F0X0000000bxm%2FwzSpqanh6CU9O3YYVzEaur_yvZDFmgqrltzA96wKEFk&asPdf=false
Posted on January 10, 2018 at 01:21

I'm sorry I copied 2 SystemClock_Configs()  in the prior paste.  Ignore the SystemClock_Config1() as it is not used. The System clock is configured prior to configuring any peripherals.  The clock configurations is straight from the F722 I2C example code and the I2C peripheral works correctly.   As I said, I removed the solder bridges from SB132 and SB133 and they are open now.  PA11 and PA12 are routed to pins 14 and 12 of the CN12  connector pinouts and that's where I'm looking for the CAN TX signals. I see a RX signal when I send a packet from a USB/CAN dongle.

The main sequence is as follows:

int main(void)

{

/* Enable the CPU Cache */

CPU_CACHE_Enable();

/* STM32F7xx HAL library initialization:

- Configure the Flash prefetch

- Systick timer is configured by default as source of time base, but user

can eventually implement his proper time base source (a general purpose

timer for example or other time source), keeping in mind that Time base

duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and

handled in milliseconds basis.

- Set NVIC Group Priority to 4

- Low Level Initialization

*/

HAL_Init();

/* Configure the system clock to 216 MHz */

SystemClock_Config();

/* Configure LED1 and LED3 */

BSP_LED_Init(LED1);

BSP_LED_Init(LED3);

/* Configure User push-button */

BSP_PB_Init(BUTTON_USER,BUTTON_MODE_GPIO);

&sharpif CAN

/*♯♯-1- Configure the CAN peripheral ♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯*/

CAN_Config();

/* Enable interrupt driven CAN Receive */

if (HAL_CAN_Receive_IT(&CanHandle, CAN_FIFO0) != HAL_OK)

{

/* Reception Error */

Error_Handler();

}

&sharpendif

while (1)

{

/* Wait for User push-button press before starting the Communication */

while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_SET)

{

}

/* Delay to avoid that possible signal rebound is taken as button release */

HAL_Delay(50);

/* Wait for User push-button release before starting the Communication */

while (BSP_PB_GetState(BUTTON_USER) != GPIO_PIN_RESET)

{

}

&sharpif CAN

// if (sendit == 1)

{

/* Set the data to be transmitted */

CanHandle.pTxMsg->DLC = 3; // ♯ of bytes

CanHandle.pTxMsg->Data[0] = 5;

CanHandle.pTxMsg->Data[1] = 4;

CanHandle.pTxMsg->Data[2] = 3;

/*♯♯-3- Start the Transmission process ♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯*/

if ((HAL_CAN_Transmit(&CanHandle, (uint32_t)10)) != HAL_OK)    // this function returns HAL_OK

{

/* Transmission Error */

// Error_Handler();

 err = 1;

}

sendit= 0;

}

&sharpendif

}

}

}

A very close derivative(clocks different of course) of this works on the F303 Nucleo board.  Any thoughts appreciated.

Thanks,

Posted on January 10, 2018 at 01:24

And you have a transceiver attached?

964 kbps

Confirm it runs the initialization code in the debugger.

Use the debugger to confirm the RCC, GPIOA and CAN1 have been configured as expected with 'peripheral view'

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 10, 2018 at 01:32

Yes, I have a transceiver.  I unplugged  a working F303 board and plugged the F722 in so all the rest of the system works.  I'm not sure what 'peripheral view' is but I will find out.  I've stepped through the setups and all are returning HAL_OK return values.  I can also swap out the CAN code for I2C code using the same SystemClock_Config() and the I2C works fine, I think indicating that the clock is setup.  

I don't see a 'peripheral view' in the IAR workbench.  Am I missing something?

Posted on January 10, 2018 at 02:09

I'm using Keil, not IAR, where the peripherals can be pulled up in assorted panes were you can drill down into the register/bit levels.

https://www.iar.com/support/resources/articles/debugging-with-microcontroller-registers/

Clock configuration looks reasonable for an HSE of 8 MHz, value of HSE_VALUE in stm32f7xx_hal_conf.h

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