Skip to main content
Micha Valach
Associate III
December 29, 2016
Question

Integrated new Bluetooth BLE code, into an existing old project based on IAR5.4 ?

  • December 29, 2016
  • 2 replies
  • 1815 views
Posted on December 29, 2016 at 07:30

Hello,

I'm newbie in the Bluetooth business, I purchased theSTM32L476RG Nucleo+Nucleo BLE expensionboard (X-Nucleo-IDB05A1withSPBTLE-RF module) .

Then I installed the

IAR 7.5 workbench

,copy the

X-Cube-BLE1directories including the samples code - and everything

works like a charm !!!

As we would like to enhance ourexisting old project (based onSTM32F101CBT6andIAR5.4 workbench) with new Bluetooth BLE capabilities,

Please advise,if the samples code from the new Bluetooth BLE project (X-Cube-BLE1) can be integrated into existing old project which use the following environment, based on

STM32F101CBT6

and

IAR5.4 workbench

)?

If NO, please advise,how can we overcome this obstacle.

Thanks In Advance,

Micha Valach

#st-bluetooth

Note: this post was migrated and contained many threaded conversations, some content may be missing.
    This topic has been closed for replies.

    2 replies

    Antonio Vilei
    ST Employee
    January 17, 2017
    Posted on January 17, 2017 at 15:25

    Dear

    Micha Valach,

    from the version of IAR that you are using, I assume that your old project is based on the old Standard Peripheral Libraries (SPL) and not on the new STM32Cube.

    Please notice that the Bluetooth Low Energy (BLE) drivers and examples in the X-CUBE-BLE1 package are based on STM32Cube.

    There could be two different ways of adding BLE to your project:

    1) move everything to STM32Cube and reuse drivers and examples of X-CUBE-BLE1;

    2) use drivers and examples from the STSW-BLUENRG-DK package, which includes support for the old SPL libraries:

    http://www.st.com/content/st_com/en/products/embedded-software/evaluation-tool-software/stsw-bluenrg-dk.html

    If you're happy with your STM32F1 chip, the second option would probably be the fastest for you. However, if in the future you plan to embrace other series of STM32, you could consider moving to STM32Cube as there is no SPL support for the latest MCUs (L4, L0, and so on).

    Hope that helps,

    Antonio

    Rashedul Islam
    Associate II
    September 21, 2017
    Posted on September 21, 2017 at 11:43

    Hello

    Vilei.Antonio

    ,

    I tested the

    X-CUBE-BLE1 on SensiBLE board and also STM32L476RG with expansionX-Nucleo-IDB05A1. It works fine for both the boards and can connect with mobile phone BlueNRG android App.

    Now we want to integrate the blueTooth module in custom project where we are using

    STM32L476ZETx

    . Can you tell me is it possible to use theX-Nucleo-IDB05A1? And if Yes, what is the easiest way? Is there any guid availble to easily poritng the Bluetooth module?

    Antonio Vilei
    ST Employee
    September 21, 2017
    Posted on September 21, 2017 at 16:51

    Hi Rashedul Islam,

    in your case, as the MCU you have chosen is very similar to the one that you have already tested, I'd suggest to start from that same example in the X-CUBE-BLE1 package, and then configure the correct MCU from the project options of your IDE. As the pins configuration is probably different, you will need to update the Drivers\BSP\STM32L4xx_Nucleo\stm32l4xx_nucleo_bluenrg.h

    file according to your case.

    in general, if you're starting from scratch with any STM32-based custom board, I think that the easiest path is probably using CubeMX to generate the base code for your target MCU and then add the relevant files for Bluetooth Low Energy (BLE).

    Since the BlueNRG-MS chip communicates via SPI

    , from CubeMX GUI make sure to enable SPI support and configure the pins according to how the BlueNRG-MS chip (the one inside X-Nucleo-IDB05A1) is actually wired to your board.

    You can see which pins you need to define by taking a look at the Drivers\BSP\STM32L4xx_Nucleo\stm32l4xx_nucleo_bluenrg.h file of the X-CUBE-BLE1 package.

    You need to copy the stm32_bluenrg_ble.c and stm32_bluenrg_ble.h files from the

    Drivers\BSP\X-NUCLEO-IDB0xA1 directory, as they implement the interface between the BlueNRG-MS and the STM32 MCU.

    You also need to add the BLE specific files from the

    Middlewares\ST\STM32_BlueNRG\SimpleBlueNRG_HCI

    directory.

    Best regards,

    Antonio

    Antonio Vilei
    ST Employee
    September 29, 2017
    Posted on September 29, 2017 at 16:05

    You're welcome!

    Rashedul Islam
    Associate II
    October 6, 2017
    Posted on October 06, 2017 at 12:10

    Hi

    Vilei.Antonio

    Sorry I havae to come back again.....

    There were some changes on my board and BT_IRQ is defined as

    PF6 (previously it was PE1). So I changed the following

    #define BNRG_SPI_EXTI_IRQn EXTI9_5_IRQn

    #define BNRG_SPI_EXTI_IRQHandler EXTI9_5_IRQHandler

    But now from android device it connects but after a while it disconnect saying error : 'Peripheral Disconnected!'

    I think the SPI comuncation has no problem. But somehow it is getting disconected.

    Antonio Vilei
    ST Employee
    October 6, 2017
    Posted on October 06, 2017 at 16:26

    Please try enabling the debugging option for SPI by uncommenting the ♯ define PRINT_CSV_FORMAT line in 'Middlewares\ST\STM32_BlueNRG\SimpleBlueNRG_HCI\includes\debug.h' file. After you enable this option, you will see the log of the low level SPI commands and events being exchanged between your STM32 and the BlueNRG-MS chip. For example, if you are using IAR EWARM, you can see the output messages by using the View -> Terminal I/O option from the menu while you're code is being executed by the tool via ST-Link. Assuming that the SPI communication is working properly, from that log it will be easier to understand what's going on.