Microcontroller C programming

There is no doubt that everyone faces C language when programming microcontrollers. This is most popular language among hardware programmers. There are plenty books about this language – you just have to open and read. This article is not about language basics, but there is effectiveness of c language in embedded systems touched. Quite often you can find good examples of effective algorithms: faster code performance and code size as well. In order to write good optimal algorithm you have to know structure of compiler. Of course we are not going to analyze compilers, but we can look through few rules and tricks and achieve optimal algorithm. Begining What to do when limit of program size is overrun or there is not enough speed in some cases. Of course you will say, that these parts it is best to write in assembler, but is this a solution? Maybe there is a way to do this with C? Not a secret, that the same result can be achieved in different ways, e.g. some programmers like to use dynamic variables other arrays, some like to use case other if statements. This is a Programming Style and mostly everyone has its own style.…

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

ARM7 LPC2148 mini board

One day I’ve got ARM LPC2148 chip in my hands. The Philips LPC2148 is an ARM7TDMI-S based high-performance 32-bit RISC Microcontroller with Thumb extensions 512KB on-chip Flash ROM with In-System Programming (ISP) and In-Application Programming (IAP), 32KB RAM, Vectored Interrupt Controller, Two 10bit ADCs with 14 channels, USB 2.0 Full Speed Device Controller, Two UARTs, one with full modem interface. Two I2C serial interfaces, Two SPI serial interfaces Two 32-bit timers, Watchdog Timer, PWM unit, Real Time Clock with optional battery backup, Brown out detect circuit General purpose I/O pins. CPU clock up to 60 MHz, On-chip crystal oscillator and On-chip PLL. < p align=”left”>Looks like it can be powerful thing in good hands. I decided to test its power, so I needed development board, which could I use for my experiments. Because I wanted to have more universal board, so I faced few problems – PCB tracing. My purpose was to make this PCB at home, so I didn’t want to waste time while tracing big board with many tracks. There were two ways of making it: make one big board with complicated tracing of PCB tracks, or split it in two parts. I’ve chosen second one. In a…

Continue reading