What are differences between WinARM and WinAVR

Everyone who is working with AVR microcontrollers knows this powerful tool – WinAVR which is completely open source and does the job comparable to commercial. It already has many routine tasks included in package that you don't need to worry about. So when shifting to ARM7 microcontrollers it is logical to try WinARM as nice alternative to WinAVR. WinARM tools are collected by Martin Thomas and put in one distribution package ready to use under Windows platform. But in fact these tools are very different despite there is same GCC compiler used. First of all WinAVR is targeted to one manufacturer(ATMEL) AVR microcontrollers. One core allows to robust many routine tasks as RAM, ROM defining. WinARM targets various manufacturers who produce microcontrollers with ARM core which may vary in type. The arm-gcc toolchain is also very different from avr-gcc because of different MCU core architecture, memory organisation. For example cede can be executed form ROM and RAM memory. These all flexibilities of course implies in complexity in tools. I think trickiest part of preparing project is initializing MCU. Defining has to be done before main program flow. In WinARM you have to do this by yourself – by writing startup…

Continue reading

LPC2000 watchdog timer

As in all microcontrollers watchdog timers purpose isto reset microcontroller after reasonable amount of MCU error time. If watchdog is enabled and if after some time watchdog timer doesn't reload due correct program flow, then it generates a system reset. Watchdog unit consists of four registers: WDMOD – Watchdog mode register where is watchdog mode and status saved. There are three watchdog modes available in LPC2000: Debug mode – allows to debug code with watchdog active but without WD reset; Watchdog Interrupt mode – generates interrupt when WD timer overflows; Watchdog Reset mode – reset MCU when WD timer overflows. WDTC – Watchdog timer constant register where time out value is saved. Timeout value can be determined by formula: Period=Pclk·WDTC·4. While WDTC value can be in range from 256 to 2^32, then timeout when Pclk=60MHz can vary from 17.066us to 5min. WDFEED – watchdog feed sequence register. Writing 0xAA followed by 0x55 wil reset Watchdog to WDTC value. WDTV – watchdog timer value register holds current watchdog timer value which can be read. When started watchdog timer must get regular feed sequence in order to avoid reaching zero and reset.

Continue reading

JTAG wiggler clone for ARM microcontrollers

The Olimex ARM JTAG clone is well known as there are many schematics in the internet available. Circuits is very simple and seems to be reliable. This adapter can be also set up to work with WinARM tools: ocdremote and gdb/Insight-gdb. In the circuit there is a critical part that needs to be considered – 74HC244 buffer IC. Family of HC support less than 4.8V if powered with 3.3V. But reality shows that Parallel port voltage usually is lower than 5V, so HC will fit. But of course it is better to measure the HIGH state of parallel port pins. To be more sure HC should be replaced by 74LVP244 or 74LPT244. These chips support 5.5V in entry with 3.3V supply but sometimes they are hard to find in the market.

Continue reading

Real time clock of LPC2148

LPC2000 series of microcontrollers have built in Real Time Clock(RTC) unit which is may be used for counting time in order to maintain a calendar and clock. RTC is designed for low power designs that enables to use in battery powered designs. Real time clock is capable to count time in Seconds, Minutes, Hours, Days of Month, Months, Years, Days of the week and Days of Year. Real time module can be clock using distinct 32kHz clock oscillator or internal prescaller from VPB clock. Real time clock unit has additional power supply pins(3.3V) what allows RTC clock to work when system is off – actually power down mode operated from clock battery. As there are many functions in clocks like time units(seconds, minutes, etc,) and alarms, there are quite a number of registers to cover clock functionality. There are several groups of registers: Miscellaneous registers like Interrupt Location Register(ILR), Clock Tick Counter(CTC), Alarm Mask Register(AMR); Time Counter register Group which includes registers that contain Time values(Seconds, Minutes,…); Alarm register group – registers that hold alarm settings and that are compared to Time Group registers. When match occurs an interrupt is generated; Registers that control Reference Clock Divider – with these…

Continue reading

Pulse Width Modulator in LPC2000 ARM7 MCU

In ARM7 microcontrollers PWM is designed as separate module but it has all features as a general purpose timers have, just limited pins are associated. PWM module have improved match module which allows to have six channels of single edge controlled PWM or three double edge controlled PWM. There are seven match registers used with improved update logic. PWM modulator have additional shadow match registers that perform latch effect. This means that you can update match registers on instantly, but new values are taking effect only at the beginning of new cycle. This mechanism ensures that all updates are performed at he beginning of a new cycle through latch enable register(LER). In general purpose timers match registers take effect immediately after they are updated.

Continue reading

Timer Counters in LPC2000 microcontrollers

LPC2000 microcontrollers have at least two 32 bit timer counters. Lets take LPC2148 microcontroller where are two general purpose 32 bit timers that are identical except peripheral base address. These timers are for general purpose that can perform timer and counter operations. Timers have many features: Programmable 32 bit pre-scaler; Up to four 32 bit capture channels that can take snapshots with interrupt generation ability; Four 32 bit match registers that allow generate interrupt on match, generate interrupt and stop timer, generate interrupt and reset timer; Up to four output pins that can be set LOW/HIGH/TOGGLE on compare match;

Continue reading

General purpose ports in ARM MCU

Microcontrollers aren't imaginable without ability to interact with other devices like indicators, input devices or other off-chip devices. For this every MCU have I/O pins that are used to interact with external world. General purpose I/O ports can be accessed via registers who provide enhanced features or simply via port registers. Port registers are allocated to the ARM bus so that fasted possible timing can be achieved. Control of individual bits is possible using single instruction. All port registers are byte and half word addressable. After MCU reset all I/O ports are set to input. Lets take LPC2000 series ARM microcontroller LPC2148. It has two 32 bit general purpose I/O ports PORT0 and PORT1. PORT0 has 30 pins for input/output operations where one is only for output. PORT1 has 16 available pins for GPIO. Each GPIO pins is controlled by four registers: IOPIN – port pin value. Depending on pin direction settings the value from this register can be read; IOSET – Writing “1” to this register sets port value to high state while writing 0 hasno effect. This register works in conjunction with IOCLR; IOCLR – This register is opposite to IOSET. Writing “1” value to it will set…

Continue reading