Constants in C language

Constant value is understandable as nonchangeable value like PI=3.141592… value in math. Usually, you use constants in your programs, but don’t realize that they are constants. For instance: x=x+3; The number 3 is a constant which will be compiled directly in addition operation. Constants can be character or string. Like in function printf(“Hello World\n”); “Hello World” is a string constant that is placed in program memory and will never change. It is usually recommended to declare constants by using identifier with reserved word const: const int No=44; Identifying the variable as constant will cause the compiler to store this variable in program memory rather than in RAM, thus saving space in RAM. If special functions are used, then constants can also be stored in EEPROM memory.

Continue reading

The very basics of C

C language is a function-based programming language. C program itself is a function. Usually, parameters to the C function are passed as arguments. The function consists of a name followed by the parentheses enclosing arguments or an empty pair of parentheses if there are no arguments required. If there are several arguments, they are separated by commas. The mandatory part of the C program is the main function. This function must be included in every program because it is the first function run after its execution. Lets take an example: This is an elementary C program, but it contains all the necessary elements. Let’s examine a little bit about what we have written here…

Continue reading

Microcontroller C programming

There is no doubt that everyone faces C language when programming microcontrollers. This is the most popular language among hardware programmers. There are plenty of books about this language – you have to open and read. This article is not about language basics, but c language’s effectiveness in embedded systems touched. Quite often, you can find good examples of effective algorithms: faster code performance and code size. To write a good optimal algorithm, you have to know the structure of the compiler. Of course, we will not analyze compilers, but we can look through a few rules and tricks and achieve an optimal algorithm.

Continue reading

GNUARM for ARM microcontrollers

In this article, you’ll find some information about how to configure the GNUARM toolset for compiling ARM7 microcontrollers.GNUARM is the open-source toolset for ARM7 MCUs. It has a GCC compiler and debugger. Our purpose now is to set up tools in a Windows environment and compile one project.First of all download the compiled toolset from https://www.gnuarm.com: Select the newest [GCC-4.0 toolchain] located below 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 the desktop shortcut to be placed. I highly recommend checking Cygwin DLL because I had to copy DLLs to copy manually despite I had Cygwin installed. If this option is checked, 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 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 compilation. Let’s try the test compilation. Just download the project…

Continue reading

ARM7-Base development board for LPC2148

After the ARM mini-board for LPC2148 is created, it’s time to develop a development board. I want to make the board as universal as possible.So I decided to put I2C, SPI, COM, and JTAG on board. I decided to use an external voltage adapter as there are needed 5V and 3.3V DC sources. For my experiments, I can use those voltages straight from a PC source. 5V there is used to supply MAX232IC. I decided to use it instead of MAX3232 because it is easier to get them in the market. Of course, I left the ability to use and MAX3232 by changing the jumper. All other free pins I made accessible by adding pinheads inboard.

Continue reading

ARM7 LPC2148 mini board

One day I’ve got an 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, a 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.

Continue reading