Minimizing microcontroller code size

Reducing microcontroller code size isn’t ease task, but what if you want resulting code to fit your available memory? Minimizing microcontroller code size can be done in two ways: Firs is using compilers optimization feature by code size. This optimization is very dangerous. Your optimized code may not work as supposed to because compiler may eliminate some code like empty loops or adding zeros. For example compilers like to remove for(int i=0;i by leaving one or several iterations. So don’t think that your optimized code will work as un-optimized. There are other things you can do to minimize microcontroller code size. One of them is avoiding usage of standard libraries routines. Because these libraries are general and handles all standard possible execution cases. By including them in your design you include a bunch of code you dont need. If it is possible it is better to write your own routines or modify existing ones to fit your needs. Also try to use needed variable sizes. If you need unsigned integers use uint type if you need byte size avoid using int which usually is more than 8 bits (16 or 32). This may significantly reduce your code as there are fewer…

Continue reading

Increase microcontroller code efficiency

C compilers are getting more and more advanced, but there is always a trade off made between speed and code size. Compiled code can be faster or smaller but not both. So you have to choose which part is more important speed or code size. The Increase of microcontroller code efficiency can be done in many ways. Don’t trust compiler optimization features, as they might not bee as effective as you expect. It is better to grab some profiler and inspect what parts of your code takes the most time and size. It is better to follow some techniques that may reduce code execution time and increase microcontroller code efficiency:

Continue reading

First LPC2148 ARM7 microcontroller test – led blink

This is simple led blinking routine using my development board. The compiler I used was WINARM. I like this compiler because its free and adaptation is easy while the same functionality is in WINAVR. This simple test just blinks pin 16 of port 0. This I used when I first got to know ARM microcontroller. Here is the main code: /************************************************* * WinARM Demo P0.16 blink **************************************************/ #include “types.h” #include “LPC214x.h” #include “config.h” #include “armVIC.h” #define IOPINS016 16 static void lowInit(void) { // set PLL multiplier & divisor. // values computed from config PLLCFG = PLLCFG_MSEL | PLLCFG_PSEL; // enable PLL PLLCON = PLLCON_PLLE; PLLFEED = 0xAA; // Make it happen. These two updates PLLFEED = 0x55; // MUST occur in sequence. // setup the parallel port pin IO0CLR = (1< IO0SET &= ~(1< IO0DIR =(1< // wait for PLL lock while (!(PLLSTAT & PLLSTAT_LOCK)) continue; // enable & connect PLL PLLCON = PLLCON_PLLE | PLLCON_PLLC; PLLFEED = 0xAA; // Make it happen. These two updates PLLFEED = 0x55; // MUST occur in sequence. // setup & enable the MAM MAMTIM = MAMTIM_CYCLES; MAMCR = MAMCR_FULL; // set the peripheral bus speed // value computed from config.h VPBDIV = VPBDIV_VALUE;…

Continue reading

Philips introduces advanced Hi-Speed USB microcontrollers

Royal Philips Electronics introduced the LPC2800 series – the industry’s most advanced ARM-based Hi-Speed USB microcontrollers on the market. The Philips LPC2800 is the first ARM7 MCU to deliver USB 2.0 device capabilities with maximum standard compliance and an on-chip Hi-Speed 480 Mbits/sec transceiver, and the first to enable single battery cell operation. These unique features allow embedded system design engineers to incorporate new capabilities into products such as PC peripherals, SD memory cards, smart card readers, and other USB battery-powered devices – all at a competitive price point. More at www.semiconductors.philips.com

Continue reading

ARM7 Development Tools

The development Software Keil for architecture ARM7 TDMI support the following devices ARM7: Atmel, Philips and Analog Devices, Sharp, OKI, ST Microelectronics. Instrument for ARM consist of the following parts: – CAARM Compiler/Assembler Kit Contains AARM Assembler, ARM Utilities, CARM Compiler, LARM Linker/Locator and the integrated medium of the development of Вµ.Vision IDE, which accomplishes complete control Compiler, Assembler; – PKARM – Professional Developer’.s Kit Includes all components CAARM plus of Вµ.Vision Debugger, which supports the complete simulation of devices and OS of the real time RTXA-Tiny; – DKARM Developer’s Kit – is included the integrated medium of the development of Вµ.Vision IDE and ВµVision Debugger; – Ar- ARM advanced Rtx- ARM the operating system of the real time Keil Rtx-ARM, which includes Flash File System and support TCP/IP Networking; – ULINK – adapter Usb-jtag for the connection of interface JTAG ARM7 to port USB of personal computer. Keil ARM Tools Makes it possible to select, which of compilers and assemblers to use in the project: – GNU ARM Compiler, Assembler – freely extended ON, does not have limitations according to the functions and the size of the code and is supported DKARM. It is used, if the purpose of…

Continue reading

GNUARM for ARM microcontrollers

In this article you’ll find some information about how to configure GNUARM toolset for compiling ARM7 microcontrollers. GNUARM is the open source toolset for ARM7 MCUs. It has GCC compiller and debugger. Our purpose now is to set up tools in Windows environment and compile one project. First of all download compiled toolset from https://www.gnuarm.com: Select the newest [GCC-4.0 toolchain] located bellow Cygwin. After it is downloaded, start the installation: Start window Accept license agreement. Select folder where do you want GNUARM to be installed: Select the components. You can select all of them. Chose Start menu folder name – just leave as it is. Select desktop shortcut to be placed. I higly recoment to check Cygwin DLL, because despite I had cygwin installed, but I had to copy DLLs to copy manually. If this option ischecked, DLL files will be copied without bothering you. And press install.. Select checkbox in order to create system variable: PATH=c:\gnuarm\bin After we have GNUARM installed, download binutils from https://optimize.ath.cx/ARM7/src/utils.zip. Download this archive and unpack all contents to c:\gnuarm\bin folder. Also download https://optimize.ath.cx/ARM7/src/cygncurses-8.dll and put it in c:\gnuarm\bin folder. Now we are set to start compillation. Lets try test compillation. Jus download project from…

Continue reading

ARM7-Base development board for LPC2148

After ARM mini board for LPC2148 is created its time to develop development board. I want to make board as universal as possible. So I decided to put I2C, SPI, COM and JTAG on board. I decided to use external voltage adapter as there is needed 5V and 3.3V DC sources. For my experiments I can use those voltages straight from PC source. 5V there is used to supply MAX232IC.I decided to use it instead of MAX3232 because it is easer to get them in market. Of course I left ability to use and MAX3232 by changing jumper. All other free pins I made accessible by adding pinheads in board. I made 100x100mm double sided PCB PCB Bottom image PCB top image (when printing – use mirror function) And real world images. PCB Bottom Completed soldered board with ARM mini board on top. And of course I put Eagle3D traced board images. Best regards to Matthias Weißer from www.matwei.de did great job to do such job. The first read/write tests I run with Philips Flash Utility were successful. Next time I’ll post few articles how to get this board running by writing C code, compiling and flashing the ARM7 LPC2148.…

Continue reading