LPC2148_Demo updated with IAP, WDT, DAC, SWI and I2C demos
(In-Application Programming, or writing flash from within a program),
watchdog handling, outputting a waveform on the DAC, software
interrupts (SWI), and I2C functionality.
The IAP code allows interrogating the boot loader version, processor
ID, erasing, filling and blank checking flash sectors from the CCI
(Console Command Interpreter). The code itself shows how to prepare a
sector, erasing, writing and comparing. There are checks to make sure
you don't inadvertently erase sectors with code in them.
The WDT code allows enabling the watchdog. The 'dog is fed each time
is pressed. If no command is entered within 10 seconds, the
'dog times out and resets the board. The 'wdt status' command shows
the current watchdog status, how long until the next time out would
have been, and what caused the previous reset (POR, /EXTIN, WDT, or BOD).
The DAC is demonstrated by outputting a 0.078125Hz waveform. Hooking
up a 'scope or DVM to the AOUT pin will show a waveform starting at
0V, rising slowly to 3.3V, falling to 0V, and repeating. The sensor
task (which runs every 100ms) adjusts the DAC by 1/64 of it's range.
The SWI code shows how to write a SWI dispatcher, handle some
functions in assembly, and if not handled in assembly, pass it on to a
handler written in C. Unlike most SWI implementations, this one is
documented :) (As a side note, I'm new to the ARM cores, and this was
my first stab at any ARM assembly longer than 2 instructions. Having
used 8031s, Z80s, 6809s, 68Ks, PICs, x86, MSP430s, AVRs and a few
others, this is by FAR my favorite. Almost makes me want to start
writing in assembly full-time again).
The I2C code demonstrates an I2C implementation with simple polling
(the next version will have an interrupt driven state machine
implementation). I'm fully aware that two of the functions may never
return if the I2C bus is hung (SCL stuck low, for instance). If you
have an LM75 to connect to the I2C bus, there are some CCI commands to
read and write the various LM75 registers.
The package is available at http://jcwren.com/arm. Version 1.10 is
the most recent. The updated README file is also available in the
The Makefile now has some defines that determine what the console port
will be. The included .hex file is built with the USB port as the
console. By editing the Makefile and recompiling, the console can be
on UART0 or UART1.
The CCI now also include the 'md' command, for dumping memory. This
is mostly useful when using the 'iap' commands to see if the sector
really was erased or filled, but is also useful for just poking around.