Astrobe for LPC2000 Source Code

ARM Oberon Development System for Windows

Version 5.2 Copyright © 2006-2018 CFB Software
Last Updated 26 Jan 2018

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

Oberon Examples

The source code examples are grouped in subfolders in your Windows Astrobe-v5.2\Examples folder:

NOTE: Additional examples can be found in the LPC2000 Source Code Examples section of the Astrobe Forum.

The general examples should work with little or no modification on any of the supported LPC2xxx targets. Header comments in each of the source code files list the target microcontrollers that the examples were designed for. 

The example programs which are shown with screenshots below use the Out library module to generate the text output and send it to UART0. The UART0 socket should be connected to a dumb terminal or terminal emulator running at 38,400 Baud.

Folder Filename  Description
General Blinker.mod Blinker
Blinks an LED once per second using Timer0.   
General 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.


General ViewMemory.mod ViewMemory
Outputs the contents of 256 words of memory starting from address 00000 0000H and then 256 words of memory starting from address 01000 0000H. Each line of output contains the address and the contents of the next 4-word block of data displayed in Hexadecimal format.


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

General Extensions.mod
Lists.mod
Extensions
Shows how Oberon's Type Extension feature can be used 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.

General ShowTime 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.

General 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.

General IAPDemo.mod In-Application (IAP) Programming
Uses the LPC2000 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. Compare a range of identical bytes
4. Compare a range of dissimilar bytes 

ADC / LED7 LED7.mod
LED7Seconds.mod
LED7ADC.mod
ADC / 7-Segment LED Examples
Led7ADC displays a number in the range 0 to 9 relative to the rotation of a potentiometer connected to an ADC channel. Led7Seconds increments the number displayed every second. Both examples import a utility module Led7.mod which displays a single digit on a 7-segment LED that is connected directly to GPIO pins.
IRQ IRQTimer.mod
IRQBlinker.mod
Interrupts Example
Blinks an LED once a second by handling interrupts (IRQ) generated by Timer1.
IRQ FIQTimer.mod
FIQBlinker.mod
Fast Interrupts Example
Blinks an LED once a second by handling fast interrupts (FIQ) generated by Timer1.
IRQ IRQFIQ.mod
IRQ interrupted by an FIQ
Timer0 generates IRQs and Timer1 generates FIQs. The IRQ handler stays in an infinite loop which only terminates when it is interrupted by an FIQ. If you need convincing, see what happens when you comment out the statement

  inIRQ := FALSE;

in FIQTimerHandler.

SPI LedSeconds.mod 7-Segment LED Counter using SPI
Displays 0 - 9 seconds counter on a 7-segment LED connected via an SPI0 bus.
SPI MMC.mod
ReadCard.mod
Reading an SD Card using SPI/MMC
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.

I2C Temperature.mod
Reading a temperature sensor via the I2C bus

Monitors the current reading of an NS LM75 or TI TMP102 temperature sensor connected as a slave device to the I2C0 bus. The device is interrogated every second and the value is written to output whenever it changes.

NOTE: Change the CONST value I2CBUS in the source code to 1 if you want to use it with a sensor on the I2C1 bus of an LPC2103 microcontroller.

I2C Compass.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.

NOTE: Change the CONST value I2CBUS in the source code to 1 if you want to use it with a compass on the I2C1 bus instead of the I2C0 bus.

I2C EEPROM2K.mod Reading / writing an EEPROM via the I2C bus
Read a string and a counter from a 2kbit EEPROM via the I2C0 or I2C1 bus. If the string doesn't equal "Astrobe" the program has not been run before and the counter is set to zero. The counter is displayed, incremented and then written back to the EEPROM.

e.g. when the application has been run eleven times: 


When the application is run the next time:
 

NOTE: Change the CONST value I2CBUS in the source code to 1 if you want to use it with an EEPROM on the I2C1 bus instead of the I2C0 bus.
I2C EE256Demo.mod
EEPROM256K.mod
TestData.mod
Reading / writing a 256Kbit  EEPROM via the I2C bus
The program prompts the user for an EEPROM address and one of five actions:
  1. Writes the contents of a record with a variety of data types to the specified address of a 256Kbit EEPROM using paged writes
  2. Reads the data from the specified address of the EEPROM and compares it against what was originally written
  3. Overwrites every byte of the data with the value 0FF
  4. Writes the value 0FF to every byte of the entire EEPROM
  5. Exits the program
NOTE: Change the call Init(I2C0) to Init(I2C1) if you want to use it with an EEPROM on the I2C1 bus instead of the I2C0 bus.

e.g. Set the start address to 0, store the data and then read it back and compare it with what was written: 
 
LCD DigiClock.mod
LCD.mod
Alphanumeric LCD Display and Real Time Clock Example
Displays the current time on a 2x16 character alphanumeric LCD display driven by a Samsung KS0070B controller using an 8-bit data interface.
Motor StepperMotor.mod
Step Motor Example
Controls a small bipolar step motor connected to P0.12 and P0.21 as implemented on the Embedded Artists LPC2148 Education Board(V3). The application runs the motor at 5, 50 and 500 RPM for 5 seconds at each speed in clockwise and then anti-clockwise directions.
LPC2378 IRQTimer.mod
IRQBlinker.mod
Interrupts Example
Blinks an LED once a second by handling interrupts (IRQ) generated by Timer1.
LPC2378 FIQBlinker.mod Fast IO Example
Led connected to pin P0.13 configured as a fast IO pin, blinking once per second controlled by Timer0 
LPC2378 TextDisplay.mod
Display.mod
LCDEpson.mod
Fonts.mod
Fonst.res
SPI.mod
LCD Text Display Example
Redirect all text output from functions in the Out module to the Nokia 6100 / Epson display using a font store in resource data.

Target:
LPC2378 systems with a Nokia 6100 / Epson display connected to SPI0 / SSP0

Tested on:
Olimex LPC2378-STK Development Prototype Board


Licence Agreement

Astrobe for LPC2000 Examples Source Code

Copyright (c) 2018 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.