Good microcontroller tutorial

30 08 2013

http://tronixstuff.wordpress.com/tutorials/

http://arduino.cc/





2010 in review

3 01 2011

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads This blog is doing awesome!.

Crunchy numbers

Featured image

A helper monkey made this abstract painting, inspired by your stats.

A Boeing 747-400 passenger jet can hold 416 passengers. This blog was viewed about 2,200 times in 2010. That’s about 5 full 747s.

 

In 2010, there were 4 new posts, growing the total archive of this blog to 10 posts. There were 2 pictures uploaded, taking up a total of 3mb.

The busiest day of the year was September 9th with 35 views. The most popular post that day was Basic ‘C’ interview questions.

Where did they come from?

The top referring sites in 2010 were google.co.in, en.search.wordpress.com, linkedin.com, en.wordpress.com, and google.com.

Some visitors came searching, mostly for embedded systems basics, embedded system basics, embedded c interview questions, embedded c interview questions and answers, and mentor graphics interview questions.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

Basic ‘C’ interview questions December 2009
11 comments

2

Answers for Basic ‘C’ interview questions part 1 January 2010

3

Memory Segment January 2010

4

Overview of Microprocessor – 8085 (useful links) January 2010

5

Embedded System Definitions December 2009
4 comments





Simple definition for Firmware

31 12 2010

what is Firmware?

Firmware is like a set of simple programs on a hardware device that tells it how to behave

Comments are welcomed.

Wish you Happy New Year 2011.





Overview of Microcontroller – 8051

26 02 2010

In this post i have given only links. i found those links to be more informative.

Wiki page

8052.com

8051_tutorial

In next upcoming post we can see some examples program for 89c51 in Keil software





Overview of Microprocessor – 8085 (useful links)

11 01 2010

In this post i have given only links. i found those links to be more informative.

Wikipedia Link

Good Link for all processor details Link for all processor main menu

Document in under this link explains the basic of the 8085 microprocessor.

8085 questions & answer Links

  1. Wiki Answers
  2. Interview Questions

I have not gone through all the questions, but if you have any doubts or information to share please comment it, we can discuss it.

back to Topics to be discussed





Answers for Basic ‘C’ interview questions part 1

5 01 2010

question can be found in this link

1, what is qualifiers?

Qualifiers defines the property of the variable. Two qualifiers are const and volatile. The const type qualifier declares an object to be nonmodifiable. The volatile type qualifier declares an item whose value can legitimately be changed by something beyond the control of the program in which it appears, such as a concurrently executing thread / interrupt routine.

2, What is storage class? explain with example

The storage class determines the part of memory where storage is allocated for an object (particularly variables and functions) and how long the storage allocation continues to exist. In C program, there are four storage classes: automatic, register, external and static.

Auto

  • They are declared at the start of a program’s block such as in the curly braces ( { } ).  Memory is allocated automatically upon entry to a block and freed automatically upon exit from the block.
  • The scope of automatic variables is local to the block in which they are declared, including any blocks nested within that block. For these reasons, they are also called local variables.
  • Automatic variables may be specified upon declaration to be of storage class auto.  However, it is not required to use the keyword auto because by default, storage class within a block is auto.

Register

  • Automatic variables are allocated in the main memory of the processor; accessing these memory location for computation will take long time.
  • when we required to optimize the execution time, move the critical variable to processor register. this can be done by using the register key word.
  • when storage class is register, compiler is instructed to allocate a register for this variable.
  • scope of the register variable is same as auto variable.

NOTE: Allocation of register is not guaranteed always, it depends on number register available in processor and number register used for manipulation. if you define 4 variable as register storage class and and processor has only 2 register for variable allocation, then compiler will allocate 2 variable in registers and treat the remaining 2 variable as auto variable. therefore usage of register keyword should should be justified and cross checked with disassembly weather register is allocated or not.

Extern

  • For using the external global variable from other files extern keyword is used.
  • any file can access this global variable and lifetime over entire program run.

Static

  • static variable have lifetime over entire program run.
  • scope of this variable is limited based on the place of declaration.
  • if static variable is defined in a file and not inside any function, then scope of the variable is limited within that file.
  • if static variable is defined inside a function, then the scope of the variable is limited within that function.
  • we can use this variable any file and any function indirectly by accessing through pointer.

3, Explain about preprocessor?

The C preprocessor is the preprocessor for the C programming language. In many C implementations, it is a separate program invoked by the compiler as the first part of translation. The preprocessor handles directives for source file inclusion (#include), macro definitions (#define), conditional inclusion (#if), user defined compilation error and warning(#error) and compiler specific preprocessor(#pragma).

see more in wiki link

4, Write a macro with two argument A, B. where A is byte and B specifies a bit position of the byte. macro should clear the particular bit position in the given byte?

see comments section in previous post

5, Write prototype for a function pointer and array of function pointers?

see comments section in previous post

6, Explain the following definition?

char   c;
char  *pc;
const char  *pcc;
char const  *pcc2;
char * const   cpc;
const char * const   cpcc;

see comments section in previous post

7, What is dangling pointers?

see comments section in previous post

see wiki link

8, What is wild pointers?

Wild pointers are created by omitting necessary initialization prior to first use. Thus, strictly speaking, every pointer in programming languages which do not enforce initialization begins as a wild pointer. This most often occurs due to jumping over the initialization, not by omitting it. Most compilers are able to warn about this.

{

int* a;

/* a is wild pointer, it is not initialized and it may have some garbage value*/

}

correct way is

{

int* a = NULL;

}

9, Explain different memory section in processor?

See post related to memory segment

10, Explain dynamic allocation memory?

see comments section in previous post

11, In which memory section dynamically allocated memory is located?

see comments section in previous post

12, what are possible problem in dynamic memory allocation?

see comments section in previous post





Memory Segment

4 01 2010

In embedded system, Memory is divided in to 4 segments. text, data, heap and stack segment.

In text segment(code segment) is used for having the program code.

Heap segment is used for dynamic memory allocation. when malloc, calloc, realloc is used for memory allocation memory is allocate from heap section.

Stack segment is used for storing the local variables. Program can use some of the processor registers and stack for storing the local variable. when a function call is made register which is used for storing the local variable and register used for data manipulation(depends on compiler implementation, processor and number of register used in the function called) will be pushed into stack. when returning from the function these registers will also be popped from stack.

Data segment is divided into 2 segment, initialized and uninitialized data segment.

Initialized data segment contains all static and global variables initialized with non zero values.

Uninitialized data segment (also called as BSS – “Block Started by Symbol”) contains all uninitialized static and global variables initialized with zero. ‘C’ Compiler will initialized this segment with zero before calling main().

example

static int a; -> uninitialized segment

static int a =10; -> initialized segment

ROM – text

RAM – data + heap + stack.

back to Topics to be discussed





Basic ‘C’ interview questions

22 12 2009

what is qualifiers?

What is storage class? explain with example

Explain about preprocessor?

Write a macro with two argument A, B. where A is byte and B specifies a bit position of the byte. macro should clear the particular bit position in the given byte?

Write prototype for a function pointer and array of function pointers?

Explain the following definition?

char   c;
char  *pc;
const char  *pcc;
char const  *pcc2;
char * const   cpc;
const char * const   cpcc;

What is dangling pointers?

What is wild pointers?

Explain different memory section in processor?

Explain dynamic allocation memory?

In which memory section dynamically allocated memory is located?

what are possible problem in dynamic memory allocation?

i will give the answer for this questions later. I request you to give the answers, so that we can discuss answers here.

Answers can be found in this link





Von-Neumann architecture vs Harvard architecture

18 12 2009

Von Neumann Architecture

The von Neumann Architecture is named after the mathematician and early computer scientist John von Neumann. von Neumann machines have shared signals and memory for code and data. Thus, the program can be easily modified by itself since it is stored in read-write memory.

Harvard Architecture

The name Harvard Architecture comes from the Harvard Mark I relay-based computer. The most obvious characteristic of the Harvard Architecture is that it has physically separate signals and storage for code and data memory. It is possible to access program memory and data memory simultaneously. Typically, code (or program) memory is read-only and data memory is read-write. Therefore, it is impossible for program contents to be modified by the program itself.

Modified Harvard Architecture

A pure Harvard architecture computer suffers from the disadvantage that distinct mechanisms must be provided to initialize instruction and data memory. Modern Harvard architecture machines often use a non-volatile technology for the instruction memory. This allows the computer to begin execution of a pre-loaded program as soon as power is applied. The data memory will initially be in an unknown state, so it is not possible to provide any kind of pre-defined data values to the program.

One solution is to provide a hardware pathway and machine language instructions so that the contents of the instruction memory can be read as data. Initial data values can then be copied from the instruction memory into the data memory when the program starts. If the data is not to be modified (for example, if it is a constant value, such as pi), it can be accessed by the running program directly from instruction memory without taking up space in data memory (which is often at a premium).

Some intelligent ‘C’ compilers will place the const variable in program memory and access them from program memory itself (you can observe this in map file by declaring variable with and without const datatype). Some compilers will have a copy of constant values in program memory and copy those values to initialize section of data memory after boot up where constants variable will be located and initialize the remaining location with ‘0’.

Modern high performance CPU chip designs incorporate aspects of both Harvard and von Neumann architecture. On-chip cache memory is divided into an instruction cache and a data cache. Harvard architecture is used as the CPU accesses the cache. In the case of a cache miss, however, the data is retrieved from the main memory, which is not divided into separate instruction and data sections. Thus, while Von Neumann architecture is presented to the programmer, the hardware implementation gains the efficiencies of the Harvard architecture.

List of Topics

Please give your comments.





Microprocessor Vs Microcontroller

16 12 2009

Microprocessor

A device that integrates the functions of the central processing unit (CPU) of a computer onto one semiconductor chip or integrated circuit (IC). In essence, the microprocessor contains the core elements of a computer system, its computation and control engine. Only a power supply, memory, peripheral interface ICs, and peripherals (typically input/output and storage devices) need be added to build a complete computer system.

Microcontroller

A single chip that contains the processor (the CPU), non-volatile memory for the program (ROM or flash), volatile memory for input and output (RAM), a clock and an I/O control unit. Microcontroller can be called as “Computer on a chip”.

Difference between Microprocessor & Microcontroller

Main difference between microprocessor and microcontroller is, microprocessor is only CPU where as microcontroller is single chip contain CPU, memory(ROM/FLASH, RAM, EEPROM etc) and peripherals (IO ports, timers, watch dog timer, ADC, DAC etc.)

Microcontrollers are popularly used in small scale & medium scale embedded systems. Designing a system and implementing it in controllers is simple and has cost advantage compare to microprocessor. No extra work need to add memory and peripherals to the system.

Figure

Examples of microprocessor:

Intel 4004 (4 bit processor).

Intel 8008, 8080, 8085, Zilog Z80, Motorola 6800, National Semiconductor IMP-8 (8-bit processor)

National semiconductor IMP-16, Intel 8086, TI TMS 9900 (16-bit processor)

Motorola 68000, AT&T Bell Labs BELLMAC-32A, Intel iAPX432, x86, ARM processors, AMD etc (32-bit processor).

AMD64, Intel64 (64-bit processor)

Examples of Microcontroller:

Intel 8051 & its derivatives from other companies, Motorola 68HC11,  TI MSP430 series, PIC, ARM, Zilog etc.

In next post we will discuss, Processor/controller selection procedure.

List of topics

Please give your comments.