Archive for the ‘CrossWorks’ Category
Move to 32 bits ARM core
Recently I moved my projects to 32 bits ARM way. After some time thinking about various platforms, I’ve decide to abandon any Windows based tool, and trying to work only with Mac, without Parallels Desktop. For small 8 or 16 bits PIC projects, I still use MPLABX. For ARM core I’ve decide to use STM32 series.
As development tool I’ve chosen Rowley CrossWorks. They have a reasonably price for non-commercial use ($150) and the most important, a Mac Os Lion version. I’ve also bought some STM32 boards, and in that post I’ll show my steps with one of them: STM32L-DISCOVERY. The other boards I also have are STM32F4-DISCOVERY and WaveShare Port103R (great board! post more later).
STM32L-DISCOVERY Development Board
The STM32L-DISCOVERY helps you to discover the STM32L ultra low power features and to develop and share your applications.
It is based on an STM32L152RBT6 and includes an ST-Link/V2 embedded debugging tool interface, a LCD (24 segments, 4 commons), LEDs, push buttons, a linear touch sensor or touch keys.
Recent version of Rowley CrossWorks for ARM added support for ST-Link/V2 programmers, so you can connect STM32L-DISCOVERY board directly to your Mac and start ARM developing.
Environment preparation steps
To work with STM32L-DISCOVERY board in CrossWorks, we’ll need to do some preparations:
- Install CrossWorks “STMicroelectronics STM32 CPU Support Package”:
- Choose “Tools” menu, then “Package Manager…“
- In search box, write “STM32 CPU Support”
- Double click to change action to “Install”
- Install the “STM32L-DISCOVERY firmware package” (version 1.0.2):
- You’ll need to download it from the ST website;
- Unfortunately, ST doesn’t have a Mac friendly package. You will see that it’s a Windows “.exe” that install it under Program Files/STMicroelectronics directory.
- But you’re lucky. I’ve already unpack it and share over my dropbox account. Click here and unpack it on your CrossWorks projects directory.
CrossWorks project creation steps
- Creating a new STM32 project:
- Select menu “File“, then “New Project” menu item.
- Select the “STMicroelectronics” from the Categories list.
- Select the executable for STMicroelectronics STM32 from the Templates list.
- Enter the name of your project: AN3413-Current_consumption_touch_sensing
- Enter the location of your project. Create a new folder under “STM32L_Discovery_Firmware_Pack_V1.0.2/Projects/AN3413-Current_consumption_touch_sensing/CrossWorks/“
- Select the Target Processor as STM32L152RB. You can finish it from here.
- Next. Uncheck “main.c” (you don’t need that auto-generated file)
- Include Preprocessor Definitions
- Select menu “Project“, then “Properties…” menu item. The Project Manager window appears.
- Select View: Properties, Properties: All, Grouping: Categorize, Configuration: Common
- Navigating on “Settings:” and find “Preprocessor Options“
- In “Preprocessor Definitions“, include the following:
- Don’t close Project Manager window, yet.
- The “User Include Directories” uses project directory in path reference. Now we are going to include the various library include paths (.h):
- In “User Include Directories”, include the following:
- $(TargetsDir)/CMSIS_3/CMSIS/Include (necessary after after STM32 Support Package 2.14, see release notes)
- In “User Include Directories”, include the following:
- Go to Project Explorer to add the project source files (.c):
- Expand the Project
- Tap with two fingers in “Source Files”, chose “Add Existing file…”
- Add the files:
- Create a “Utilities” folder under Project ‘AN3413-Current_consumption_touch_sensing’ (Tap with two fingers and “New folder…”)
- Make it a Dynamic folder (Tap with two fingers on “Utilities” folder, then “Dynamic folder…”)
- In Directory, use “../../../Utilities/STM32L-DISCOVERY” (or navigate and find it on you STM32L_Discovery_Firmware_Pack_V1.0.2 folder)
- Create a “STM32L1xx_StdPeriph_Driver” folder, make it Dynamic, point it to “../../../Libraries/STM32L1xx_StdPeriph_Driver/src/“
- Create a “STM32_TouchSensing_Driver” folder, make it Dynamic, point it to “../../../Libraries/STM32_TouchSensing_Driver/src/“
- Your project Items need to look like this (“System Files” folder is automatically added):
At this point we can build that solution. Click on “Build” menu, then “Build AN3413-Current…” . You’ll see a little devil error like that:
Well, one fix at time. Let’s start with the message:
– THUMB Debug/AN3413-Current_consumption_touch_sensing.elf section `.DataFlash’ will not fit in region `UNPLACED_SECTIONS’
— region `UNPLACED_SECTIONS’ overflowed by 2 bytes
There’s nothing about “UNPLACED_SECTIONS” under CrossWorks for ARM Reference manual, so I’ve been opened a trouble ticket for CrossWorks support team. They are very smart and always catch what you need (if you provide them all the details).
According to support, the variable is being placed in a “.DataFlash” section which needs to be allocated into the EEPROM segment. “UNPLACED_SECTIONS” exists to catch errors when sections haven’t been placed. (Thank’s Michael Johnson from Rowley!).
And, if you look at Symbol Browser (“Tools” menu) you’ll find the “.DataFlash” 2 bytes section on the range:
Reading STM32L152RB datasheet, in the memory map section it confirms it’s the EEPROM region, so they are right. But that ugly name “.DataFlash” makes me believe that it’s Flash Memory related. Bad name, bad name…
They told me how to initialize it:
- Tap two fingers in Project ‘AN3413-Current_consumption_touch_sensing’ and select “Import Section Placement” to get a project local copy of the section placement file “flash_placement.xml“.
- Tap two fingers on file “flash_placement.xml” and select “Open With” then “Code Editor“.
Add a new segment:
<MemorySegment name="EEPROM" > <ProgramSection alignment="4" load="No" name=".DataFlash" /> </MemorySegment>
After that, your file looks like that:
Let’s work on the rest errors:
– THUMB Debug/stm32l15x_tsl_ct_acquisition.o: In function `TSL_IO_Acquisition_P1′:
— undefined reference to `__TSL_wait_CLWHTA’
— undefined reference to `__TSL_wait_CLWLTA’
A double click in that lines let you go to “stm32l15x_tsl_ct_acquisition.c” source file, from STM32_TouchSensing_Driver. Let’s do a search on it, looking for “__TSL_wait_CLWHTA“, and you’ll find the follow piece of code:
So, your problem is here: “__INLINE” isn’t supported by CrossWorks. Remove only the “__INLINE” and repeat it for “__TSL_wait_CLWLTA” function. Now, Clean and Rebuild the entire solution. That’s it! Compile Ok!
Running it on board!
Connect the STM32L-DISCOVERY board to your Mac.
- Select “Target“, “Connect…“, then select ST/LINK-V2;
- In Properties Window, select “Target Interface Type: SWD“;
- Target, Download it to board and see… it’s works!
If you want my entire project files, you download it on my downloads page. Unpack it under your CrossWorks project directory. These files contains all my entire folder.
Next post I’ll show how to compiling the other example, AN3964-Temperature_sensor.