Astrobe for Cortex-M4 Source Code

ARM Oberon Development System for Windows

Version 7.0.0 Copyright © 2006-2019 CFB Software
Last Updated 16 Feb 2019

E-Mail:   info@cfbsoftware.com
Website:   www.astrobe.com

Oberon Examples

All of the included examples can be compiled and built on all editions of the current version of Astrobe for Cortex-M4. The source code examples are located in your AstrobeM4-v7.0\Examples folders. You will find additional source code examples on the Astrobe Forum.

The example programs which are shown with text screenshots below use the Astrobe Out library module to generate text output and send it via a UART port on the development board to a COM port on the PC where it is displayed on the Astrobe terminal window. Most Cortex-M4 development boards allow the serial communication to be performed via a virtual COM port using a USB cable to connect the board to the PC.

The first group of examples should work with little or no modification on any of the supported NXP or STM32 development boards.

Filename  Description
Info.mod System Info
Outputs the linker and startup parameters specified for the current application and shows the amount of RAM remaining for use by the program. 

The following screen is just indicative of the output. There is a different version of the program for each supported MCU so the actual items and their values will vary from one to another.


ViewMemory.mod ViewMemory
Outputs the contents of the first 256 words of memory starting from address Data Start 0000H and then the last 256 words of memory up to address Data End. Each line of output contains the address and the contents of the next 4-word block of data displayed in Hexadecimal format.


TestTraps.mod TestTraps
Demonstrates the trapping and display of runtime errors.

UserTraps.mod UserTraps
Demonstrates the trapping and user-defined display of runtime errors.

Extensions.mod
ExtensionsCase.mod
ExtensionsProc.mod
Lists.mod
Extensions
Shows three different ways to use Oberon's Type Extension feature to create and scan a dynamic list of a variety of objects.

Lists
contains the generic functions to build and traverse a list of objects. Extensions contains definitions for a number of related objects. The examples used are shapes e.g. circles, rectangles etc. The application first builds a list of different shapes and then scans the list displaying the relevant dimensions and area of each shape.



Extensions uses the IS operator to perform the type tests in association with type guards.

ExtensionsCase
uses a CASE statement to perform the type tests and selections.

ExtensionsProc uses procedure variables as record fields to perform type-specific actions for the different record extensions.
ShowTime.mod
Time.mod
Set and Display the Real Time Clock 
Prompts for the input of the current time (hours, minutes and seconds) and then displays the updated time every second.


The following examples have been tested with specific combinations of development and breakout boards.

Filename  Description
Blinker.mod Blinker
Blinks an LED once per second using Timer0. You may have to change the pin configuration-related statements depending on which pins your LEDs are connected to. See the Getting Started section of the Astrobe Help file for more information.
IRQBlinker.mod
IRQTimer.mod
IRQ Blinker
Led connected blinking approx. once per second as a result of interrupt requests (IRQ) generated by a timer
ExtraRAM.mod Extra RAM for Dynamic Record Variables
Illustrates the use of the additional 32kB of AHB SRAM present on LPC4088 MCUs.

Target: 
NXP LPC40xx systems
SlideDemo.mod
Graph.mod
IO.Mod
Slide.mod
ST7735.mod
NoTrace.mod
Trace.mod
Columbia.mod
Columbia.res
StPauls.mod
StPauls.res

TFT Graphics Display
Graphics line-drawing functions. Displays AutoCAD Slide images of St Paul's Cathedral and the Columbia space shuttle on an 160x128-pixel TFT LCD colour display using SPI. The images are stored as vector graphics resource files. The images are panned and zoomed at regular intervals.

Target: 
STM32 Nucleo-64 and Nucleo-144 Systems

Tested with: 
AdaFruit 1.8" Colour TFT Shield PID: 802
+ All supported STM Nucleo-64 and Nucleo-144 boards

CalcBaudRate Calculate Baud Rate Parameters
If you are using a crystal frequency of 14.7456 MHz the standard UART baud rates can be accurately generated. If you are using a crystal operating at other frequencies you can use the library function Serial.InitEx instead of Serial.Init to achieve finer control over the baudrate. The function requires that the target MCU has an extended UART feature, the fractional divider register (FDR).

This example program calculates and displays the values of the parameters to be used with Serial.InitEx for a range of crystal frequency and baud rate combinations.

The Calculate function included in the example was designed to be efficient enough to be extracted and included in your application if you want to generate the values dynamically.

Target: 
NXP LPC40xx systems

IAPDemo.mod
In-Application Programming (IAP)
Uses the LPC1xxx on-chip In-Application Programming (IAP) functions to perform the following tasks:
1. Display the part identification number
2. Display the boot code version number
3. Display the unique device serial number
4. Display the last sector details
5. Fill the last sector with 0AAH
6. Blank check the last sector
7. Prepare the last sector
8. Erase the last sector
9. Blank check the last sector again
10. Compare a range of identical bytes
11. Compare a range of dissimilar bytes

Target: 
NXP LPC40xx systems

Accelerometer.mod
AccelerometerBurst.mod
Analog Devices ADXL337 Accelerometer
Reads the accelerometer X, Y, and Z values every 500ms and displays the values whenever the change exceeds ~1%. There are two similar examples which produce identical results. Accelerometer reads a single ADC channel at a time whereas AccelerometerBurst uses the ADC burst mode to perform repeated conversions.

Target: 
LPC40xx systems with an Analog Devices ADXL337 3-axis Accelerometer connected to ADC0

Tested with: 
SparkFun SEN-12786 ADXL337 breakout board
+ Embedded Artists LPC4088 QuickStart Board
Compass.mod
I2CConfig.mod
Reading a digital compass via the I2C bus
Monitors the current reading of a Honeywell HMC6352 digital compass connected as a slave device to the I2C bus. The device is interrogated every second and the value is written to output whenever it changes.

Target:
LPC4088 systems with a Honeywell HMC6352 digital compass connected to the I2C0 bus 

Tested with:
SparkFun Compass Module SEN-07915
+ Embedded Artists LPC4088 QuickStart Board
SDRAMHeap.mod
EMC.mod
Using 32Mb of SDRAM for Dynamic Record Variables

Access the 32Mb of EMC SDRAM on the Embedded Artists LPC4088 QuickStart board for dynamic record variables using the Oberon NEW and DISPOSE functions. The example performs the following functions:

  • Use the Oberon NEW function to allocate 1024 records each containing an array of INTEGER with ~32Kb of data.
    Populate every element of every array with a value ranging from 0 to 1024 * 8191 - 1.
    Display how much heap memory is available after the allocation.
  • Verify that none of the data has changed since it was written
  • Deallocate all the records using the Oberon DISPOSE function and display how much heap memory is now available to be reused again.Displays the letters and numbers found in the first four blocks of an SD Card that appear to contain text information. The following resulted from reading a newly-formatted 2GB SD card with a FAT file system that had the single file ReadCard.mod in its root folder.
Tested with:
Embedded Artists LPC4088 QuickStart Board
SDRAMReadWrite.mod
EMC.mod
Read/write access to 32Mb of EMC SDRAM

Read/write the 32Mb of EMC SDRAM on the Embedded Artists LPC4088 QuickStart board using the Astrobe SYSTEM.COPY function. The example performs the following functions:

  • Fill the SDRAM with integers from 0 to 8388607 (32 Mb of data) by copying the data from an array using SYSTEM.COPY, 4K bytes at a time.
  • Read back the data by copying the data to an array using SYSTEM.COPY, 4K bytes at a time and compare with the original values.
Tested with:
Embedded Artists LPC4088 QuickStart Board 
Temperature.mod
I2CConfig.mod
Time.mod
I2C Temperature Logger
Monitors the current temperature every second using the Real Time Clock and writes it, and the time, to output whenever it changes.

Target:
STM32 systems with a TI TMP102 Digital Temperature Sensor connected to the I2C1 bus

Tested on:
SparkFun SEN-09418: TI Digital Temperature Sensor Breakout
+ All supported STM Nucleo-32, Nucleo-64 and Nucleo-144 boards
 
 
HCTest.mod
HCConfig.mod
HCDir.mod
HCfiles.mod
HCDrive.mod
HCFiler Filesystem: HCTest
Inititialise an HCFiler filesystem and create a number of test files on an SDHC Card accessed via SPI1.

Tested on: 
Opus-Two MicroSD Adaptor
+ All supported STM Nucleo-32, Nucleo-64 and Nucleo-144 boards
HCReadSpeed.mod
HCConfig.mod
HCDir.mod
HCDrive.mod
HCFiler Filesystem: HCReadSpeed
Time SDHC card sector reading speed on an HCFiler filesystem accessed via SPI1.

Tested on:
Opus-Two MicroSD Adaptor +  
+ All supported STM Nucleo-32, Nucleo-64 and Nucleo-144 boards


Licence Agreement

Astrobe for Cortex-M4 Examples Source Code

Copyright (c) 2017-2019 CFB Software.
http://www.astrobe.com

Permission to use, copy, modify, and/or distribute these examples in source code form (the "Software") for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 

DISCLAIMER

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THE SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES OR LIABILITY WHATSOEVER, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DEALINGS IN OR USE OR PERFORMANCE OF THE SOFTWARE.