Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,760 members, 7,824,183 topics. Date: Saturday, 11 May 2024 at 03:19 AM

Microcontroller Programming Corner - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Microcontroller Programming Corner (16031 Views)

How To Make Circular Imageview And Rounded Corner Imageview In Android / Embedded System Tutorial #include<module2.h> :what Is A Microcontroller? / Want To Program PIC Microcontroller In Assembly Language?[enter HERE] (2) (3) (4)

(1) (2) (3) (4) (Reply) (Go Down)

Re: Microcontroller Programming Corner by solomonope(m): 4:16pm On Mar 11, 2010
@kobenol
check for the kind of 8bit processor i.e the manufacture and all those stuff.may be ur chip can support an rtos. but since it is an 8bit chip it won't be so different from the mcu's we have been talking about here.just google RTOS
Re: Microcontroller Programming Corner by Ayoshinex(m): 5:55pm On Mar 11, 2010
Although the project is too complicated for beginners but with dedications and diligent, you'll master it to the core
Re: Microcontroller Programming Corner by microscale: 11:40am On Apr 21, 2010
@kobenol
an 8-bit MCU cannot run linux. if you want to run linux try a 32-bit cpu like arm.

for microcontrollers you may want to consider ucos2.

you can get arm cortex from www.microscale-embedded.com which can run ucos2 & uc-gui. ucgui is a small rtos designed for microcontrollers. and with the gui library, you can develop graphics rich applications like games etc.

there are also bigger CPUs that can run the full linux and you can design a lot of wonderful products with them -- and they're cheap.
Re: Microcontroller Programming Corner by canachy(m): 7:36pm On Apr 30, 2010
We have defined the terms: Embedded system and Microcontroller, and have also mentioned a few tools (hardware & software) that we'll need to kick start our embedded designs successfully. I also mentioned that 8051 microcontroller will be our reference controller.

One more thing, its very important that we deal with the difference between a general purpose microprocessor and microcontroller now to avoid possible future confusions.

General Purpose Microprocessor:
1. has no ROM
2. has no RAM
3. has no input/Output (I/O) ports
4. has no timers

Microcontroller:
1. Contains Microprocessor
2. has ROM
3. has RAM
4. has I/O ports
5. has timers
6. might have ADC and other peripherals


P.S  when working with microprocessors, you must interface with external ROM, RAM & I/O ports, Timers for them to function (this makes the system bulkier and more expensive than microcontroller based systems - though it has the versatility on the amount of memory and ports)

P.P.S  The fixed amount of on-chip ROM, RAM,and number of I/O ports makes microcontrollers ideal for many applications in which cost and space are critical.



8051 Microcontroller

8051 is quite an old guy in the world of micros, yet it has maintained its popularity over the years, thus, making it our right choice.  After learning how to program this guy, you will have the choice of working with a wide range of micros that have been developed using its architecture. (eg AT89C51 by ATMEL)


lets quickly take a look at some of the features of the basic 8051 microcontroller.

1.  8051 has an 8 bit processor(this can only work on 8bits data at a time)

2.  8051 is a 40 pin (PDIP) chip

3.  8051 has 32 input/output pins

4.  8051 has 4 ports with each 8bit wide (Port0 (P0.0 - p0.7), Port1 (P1.0 to P1.7), Port2 (P2.0 to p2.7), and Port3 (P3.0 to p3.7))

4.  8051 has 4k byte of onchip memory (code memory(EPROM) new variants have EEPROM and/or FLASH memory)

6.  8051 has 128 byte of usable internal RAM (data memory) and another 128byte of unusable RAM

7.  8051 has 8 general purpose registers (R0 to R7)

8.  8051 has 20 special function registers (Accummulator (A), Stack Pointer (SP), TMOD etc)

9.  8051 has the capacitity to address a maximum of 64Kbyte of external memory (having 16 Address lines A0 - A15)

10. 8051 has 2 timers (Timer0 and Timer1)

11. 8051 has 1 USART (serial port)

12. 8051 has 5 interrupt sources (Timer0, Timer1, Ext0, Ext1, and serial transmit/receive)

Re: Microcontroller Programming Corner by canachy(m): 8:55pm On Apr 30, 2010
Microcontrollers are programable chips, therefore 8051 will be meaningless to us if we do not know how to program it.

Like every other processor, 8051 only understand Machine Language(offcourse it has its unique machine codes), however, attempting to learn these machine codes for the purpose of programming this guy might be suicidal. Anyways, that does not have to bother us as we still have other alternatives: to either use Assembly language (still a primitive language) or use any other compact high level language (like C, Basic or Pascal). These options are possible because we have "The Middle Man (Assembler or Compiler) " that helps us translate our chosen language to Machine Laguage which our 8051 understands. I hope that sounds a lot better now; Good.

In this Class, I choose Assembly Language. (People think this language is difficult; maybe, maybe not), but, IMHO, every potential Embedded developer should start with this - after u have mastered assembly, u may then procceed to C language as the case may be.



8051 Assembly Language

8051 assembly language is written using the 8051 intruction sets.

Before I start explaining the 8051 intruction sets, let us still look at some of the terms to help us understand better.

Memory - memories are spaces that you can store information

Memory location - this is the address used to access a given memory (eg 8051 has 128 data memory(RAM) - this means that we have address 0 to 127 (or call it memory location 0 to 127)). the same applies to code memory(ROM/EPROM/EEPROM/FLASH)

Registers - Register some of the memories that are used to store information temporarily, while the information could be a byte of data to be processed, or an address pointing to the data to be fetched. However, the vast majority of 8051 register are 8-bit registers. In 8051, we have 8 general purpose registers (R0 to R1)

Accumulator (A) - Accumulator is also a kind of register, but I prefer to call it "Messenger" because it can handle some instructions that even the general purpose registers (R0 to R7) cannot handle.

B - B is another kind of register that is used with Accumulator (A) to perfome multiplication


Carry Flag (C) - I call this the bit version of Accumulator. what A does for byte, C does for bit. But its much more than that. we shall treat its other uses they arise.

All the terms mentioned above have too do with the 8051 memory, we shall still treat many others as they appear our lessons.

Next we are going to be explaining some of the 8051 Instructions.
Re: Microcontroller Programming Corner by canachy(m): 1:50pm On May 01, 2010
MOV destination, source ;copies source to destination.

The instruction tells the CPU to move (in reality,
COPY) the source operand to the destination
operand


Example

Re: Microcontroller Programming Corner by canachy(m): 3:34pm On May 01, 2010
Quick notes on 8051 assembly programming

[list]
[li]Value (proceeded with #) can be loaded directly to registers A, B, or R0 – R7[/li]
[li]If values 0 to F moved into an 8-bit register, the rest of the bits are assumed all zeros.
eg. “MOV A, #5”, the result will be A=05; i.e., A = 00000101 in binary [/li]
[li]Moving a value that is too large into a register will cause an error
eg. MOV A, #7F2H ; ILLEGAL: 7F2H>8 bits (FFH)[/li]
[li][/li]
[/list]

Re: Microcontroller Programming Corner by canachy(m): 12:21pm On May 03, 2010
lets look at another Instruction (ADD)

ADD A, source ;ADDs the source operand to the accumulator

[list]

[li]The ADD instruction tells the CPU to add the source byte to register A and put the result in register A[/li]

[li]Source operand can be either a register or immediate data, but the destination must always be register A

eg. “ADD R4, A” and “ADD R2, #12H” are invalid since A must be the destination of any arithmetic operation[/li]

[li][/li]

[/list]

Re: Microcontroller Programming Corner by canachy(m): 12:26pm On May 03, 2010
I hope you are following
Re: Microcontroller Programming Corner by twichi(m): 7:00am On May 06, 2010
@all,

am still Canachy, I lost my posting priviledge when trying to continue posting on this class: I had to create a new account so as to be able to continue.

Will post something latter today. Thanks for your understanding.

Chibuzor Anyagha
Re: Microcontroller Programming Corner by canachy(m): 3:38am On May 08, 2010
Any questions so far?
Re: Microcontroller Programming Corner by canachy(m): 3:39am On May 08, 2010
Let me give you some time to absorb what we have done so far; so you can ask your questions. I know someone is lost by now, lets clear your doubts before we forge ahead.
Re: Microcontroller Programming Corner by chukxy: 6:23pm On May 08, 2010
@Canachy, I must commend you for your good works and kind gesture. More power to your elbow! Please could you clarify why Assembly language is preferred to other languages for programming Microcontrollers. For now, I have knowledge of C but not Assembly Language that is why I am inquisitive. I very much interested in Embedded Systems.
Re: Microcontroller Programming Corner by c7(m): 6:24am On May 21, 2010
@canachy & digitalman,
thumbs up^^^^,
i use to learn embedded programming in C sometimes ago but dump it because of d problem with getting a PIC and programmer.
@digitalman,
can i have ur email id.
@canach,
i will c u later on fbuk and YIM
Re: Microcontroller Programming Corner by c7(m): 6:24am On May 21, 2010
@canachy & digitalman,
thumbs up^^^^,
i use to learn embedded programming in C sometimes ago but dump it because of d problem with getting a PIC and programmer.
@digitalman,
can i have ur email id.
@canach,
i will c u later on fbuk and YIM
Re: Microcontroller Programming Corner by digitalman: 6:10pm On May 26, 2010
Re: Microcontroller Programming Corner by c7(m): 8:37pm On May 26, 2010
Thanx too.
Re: Microcontroller Programming Corner by c7(m): 8:37pm On May 26, 2010
Thanx too.
Re: Microcontroller Programming Corner by wale4x35(m): 4:00pm On Jun 02, 2010
Embedded programming is quite interesting, this thread reminds me of when i was task with interfacing 4x4 keypad with 16x2 LCD using ATMEL AT90S8515.
Re: Microcontroller Programming Corner by canachy(m): 5:19pm On Jun 02, 2010
Nairaland's Spam Bot wouldn't allow me continue with this tutorial; keeps blocking my posts, I think I have given up!
Re: Microcontroller Programming Corner by bigjaked(m): 2:33pm On Jun 08, 2010
microcontroller programming is a simple but a little bit technical way of embedding computational codes in to a chip. i deal majorly with microchip you know the PIC family. I believe in the Mattew 7:7 principle. bolleyjay@yahoo.com
Re: Microcontroller Programming Corner by MKA: 11:52am On Jun 09, 2010
Hi I am also interested in micro controller programming. But i don't have the background, am right now in my final year. Can you please guide me on the on the topic so that we can work together. M.K. Ahmad
Thanks
Re: Microcontroller Programming Corner by tallone: 4:08pm On Jun 11, 2010
y avnt there been any recent post, dont tell me ure all tired cuz i waz kinda learning a lot of cool stuffs
Re: Microcontroller Programming Corner by Toomaxi(m): 5:58pm On Jun 15, 2010
bros i am in the field so dont worry we can rub minds together
Re: Microcontroller Programming Corner by Nwata2003: 11:18pm On Jun 21, 2010
My warm greetings to everyone who has contributed in discussing microcontrollers (Canachy, Sweet Pawn, IG, Solomonope,  aksat, Sunnyben,, ), may u all keep the fire on.
I am a new baby in this field and I have a strong desire to grow in my knowledge on this, I already have some fundamental knowledge on this but I know there are a thousand and one that can be done with microcontrollers (I still need to know wink).
I want to come aboard with u guys, I pledge to contribute as much as I can and I hope u guy will still welcome me aboard.


With luv.
Re: Microcontroller Programming Corner by canachy(m): 7:50pm On Jun 26, 2010
tallone:

y avnt there been any recent post, dont tell me ure all tired cuz i waz kinda learning a lot of cool stuffs

Not tired, It's just that this Nairaland Spam bot wouldn't let my post show, don't know why
Re: Microcontroller Programming Corner by microscale: 12:11pm On Jun 27, 2010
My company is working on introducing a contract design and manufacturing service in Nigeria
The aim is to make it easier to produce electronics-based products in Nigeria. Initial emphasis is local design and assembly. while manufacturing will be handled by our partners in china.

we hope to do more and more of the manufacturing locally as we transfer the manufacturing know-how to Nigerian companies and as it becomes more economical to do so.

We are interested in working with other engineers locally in product design and development. if they're willing to work on a profit sharing arrangement.
business men and traders are also welcome as we are able to not only get them their desired products, but also get the underlying technology thereby giving them independence and the flexibility to innovate and cut costs.

check us out at : www.microscale-embedded.com
Re: Microcontroller Programming Corner by platinuman(m): 2:55am On Jun 28, 2010
Its nice to see that people are taking interest in embedded systems, am adept at circuit design and programming and i think i can be of use or service to those who are interested. For those interested, it takes dedication, determination and a lot of sacrifice.
@ solomonope, u dey sly o, u did not tell me about this, u go pay, manny
Anyone that is interested in learning should contact me on my mobile(08020785897) or e-mail addy (mannyinwang@yahoo.co.uk)
Re: Microcontroller Programming Corner by platinuman(m): 2:59am On Jun 28, 2010
@MKA i believe i can help with that contact me.
Re: Microcontroller Programming Corner by canachy(m): 1:51pm On Jun 28, 2010
since the spam bot wouldn't let us finish, I have decided to build a website for this purpose. The domain has been registered already; still uploading content. Once I have reasonable number of tutorials and projects uploaded, I will post the URL here. Remember; everything would be free; no gimmicks - its all about sharing and using our technical skills to launch Nigeria into the Technology Arena.

Best Regards

(1) (2) (3) (4) (Reply)

Sage OS (HTML5) : The Development (with download link) / Your Future As A Software Developer / Interview Questions For A Software Developer !

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 42
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.