Giter Club home page Giter Club logo

bmw_f10_retrofit_pma_from_f15's Introduction

BMW F10 with 5DL(Surround View) PMA retrofit from F15


This simple example shows how you can use an STM32 microcontroller version 105/107 to communicate between two CAN buses.

What's it for?

The BMW F10 still has the K-CAN body bus which operates at 100 kBit/s and K-CAN2 which operates at 500 kBit/. While the BMW F15 has had the K-CAN body bus removed.

In order for the PMA module from F15 to work correctly on the F10, it is necessary to receive certain statuses on the K-CAN2 bus via ZGW. The central gateway module (ZGM) links the main buses to one another. Examples of 'main buses' include FlexRay, MOST or K-CAN. This enables the Gateway function on the Central Gateway Module to exchange data between the various different bus systems.

Note: The central gateway module does not always link all the existing main buses to one another Which main buses are linked by the central gateway module (ZGM) depends on the model year and the vehicle equipment.

Connecting CAN buses to the ZGW

ZGW

Configuration

CMSIS Startup Files for STM32F10x Microcontrollers

To use two hardware CAN buses on STM32F107 it is necessary to pay attention to the new file startup_stm32f10x_cl.c located in cmsis_boot/startup. For STM32F103 controller startup_stm32f10x_md.c was used.

To set the CAN bus speed it is necessary to consider the clock frequency of the STM32 controller and set the appropriate parameters.

Parameter Description
CAN_SJW (Synchronization Jump Width) Specifies the width of the jump for synchronization. In this case, the value is set to CAN_SJW_1tq, indicating that the synchronization jump is 1 time quantum.
CAN_BS1 (Bit Segment 1) Determines the duration of the first bit segment. Here, the value is set to CAN_BS1_3tq, meaning that the first bit segment consists of 3 time quanta.
CAN_BS2 (Bit Segment 2) Defines the duration of the second bit segment. In this case, the value is set to CAN_BS2_4tq, signifying that the second bit segment comprises 4 time quanta.

These parameters define the timing characteristics of the bit segment in the CAN bus. Bit Timing configuration is a crucial part of setting up the CAN controller and depends on the characteristics of the CAN network, such as data transmission speed and network length. Properly configuring these parameters ensures accurate synchronization and communication on the CAN network.

The following settings are used in the code in can.c:

Bit Timing configuration for CAN1:

CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_Init(CAN1, &CAN_InitStructure);

Bit Timing configuration for CAN2:

CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_Init(CAN2, &CAN_InitStructure);

In can.h, the bus speed is configured for K-CAN at 100 kBit:

#define CAN1_SPEED_PRESCALE 45

and speed is configured for K-CAN2 at 500 kBit:

#define CAN2_SPEED_PRESCALE 9

the values are calculated for a 72 MHz clock.

bmw_f10_retrofit_pma_from_f15's People

Contributors

viaszx avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.