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…

Continue reading

TWI (I2C) interface on AVR

Two wire serial interfaces are included in following AVR microcontroller families: ATmega8x, ATmega16x, ATmega163x, ATmega32x, ATmega323x, ATmega64x, and ATmega128x. TWI interface is a “Philips” standard I2C. Using TWI interface you can connect up to 128 devices using only two wires: clock (SCL) and data (SDA). Only two pull-up resistors on each line are needed this interface to work properly. I2C interface circuit is open collector. This means if one of all devices has low level signal on a line, then it is ‘0’, and if all devices have high impedance state, then signal is considered to be high ‘1’. More details about TWI interface you can find on any ATmega datasheet. One of my examples Interfacing AD7416 digital temperature sensor you can find here: Analog Devices Digital temperature sensor AD7416

Continue reading

Using buttons and switches with AVR microcontrollers

In most designs you might want to put buttons and switches to control your program flow. This is not very difficult to read button state. You can connect button between pin and ground with internal pull up enabled. Then when button is pressed, then pin value will be 0 when released – 1. Of course you can use external pull-up resistor. In fact all mechanical contacts have their shortcomings – they generate multiple micro connections that can confuse AVR. Delay of this effect depends on quality of buttons or switches and can vary from 10 to 100ms.

Continue reading

Control 7 segment LED displays with AVR

LED displays are nothing more than sets of Light Emitting Diodes. The difference is that they have different shapes in order to display specific information. So driving LED displays is the same as regular LEDs. This is simple connection when there are enough of microcontroller Pins. But if you want to connect more displays you will need more microcontroller pins than it can give you. Then you need to make more advanced circuit with dynamic control.

Continue reading

Drive LED or Opto-isolators with AVR

This might be seem very simple to many of you, but I still get questions about simple microcontroller interfacing. So I will put a thread of notes about interfacing AVR microcontrollers to devices like LED’s, relays, I2C, etc. As you might know Diodes require pretty small current. This current depends on diode type and can be from 3mA up to 20mA and more. Working voltage is from 1.5 to 4V. One AVR pin can sink up to 20mA of current; it is convenient to connect diode directly to it with current limiting resistor. Never connect diode to pin without resistor – you may damage your AVR as your current may exceed the 20mA limit!

Continue reading

K-Type Thermocouples reviewed

A thermocouple is a sensor that generates an electrical potential related to the temperature. The operating principle of the sensor is base on the fact that any electrical junction between two different metals generates an electrical potential that depends on the temperature and the metals that are used. The principle applies equally well if three metals are used. In that case, there are two junctions in series, and the net potential results from the series addition of the two individual potentials. For example, if a copper iron junction is in series with an iron-tin junction, the net potential is the same as for a copper-tin junction. However, that is only true if both junctions are at the same temperature. The K-Type thermocouple is usually made of Chromel (+) and Alumel(-). The voltage generated from this sensor is 4mV/100°C. The max temperature can thermocouple withstand is 1000°C without any damage. How…

Continue reading