[Music] so next we look into microcontrollers so is the mic after looking into microprocessors so we have seen the microprocessors are basically the cpu so microcontrollers are one step ahead so you can consider it as computers there are several microcontrollers so we look into some of the standard ones or some of the well known microcontrollers but of course there are so many different microprocessors and microcontrollers are available so it is not possible to ah cover all of them in any course but anyway so hope that if you get exposed to one of those microcontrollers then you can extrapolate those ideas to other microcontrollers and get the essential features there so eight zero five one happens to be one of the ah very prominent microcontrollers ah that are there in the market and they its architecture is ah is guided by ah the design of this processor and ah along with that we have got essential modules like say ram rom and timers and all those additional peripherals ok so we will see them slowly so ah ah the basic components that you have in a microcontroller the eight zero five one microcontroller it has got 4 kilobytes of rom then 128 bytes of ram 4 8 bit io ports 2 16 bit timers or counters and one serial interface so this is the chip ah that we have ok so there are various manufacturers so this is from one such manufacturer now microcontroller so they are they can be considered as single chip computer so if you remember that in a computer system we need the components like the processor which is the cpu then we need some memory for that and out of that memory some part is the will hold the program so that is ah so they are not going to change so they can be the wrong part then there will be some part where will be storing some data so that is the ram part because that will require read write access and apart from that since the system computer system needs to interact with the outside world so there must be some ah i o ports ok so for example in 8085 also we have seen that you can use you can connect some io devices to the ports ah to the data bus line and get it as io port so similarly we can have some io port here and some other important thing component like a serial communication that is also important because for single bit communication so this serial communication is useful and when you are designing a system then many times what we need to do is the events will or need needed to be occurred ah at some particular instance of time so that way we need some very precise timing ok so we can put some delays using instructions ah and looping like that but that delay you can understand that we cannot go to a very refined level of granularity because if you even if you take the smallest ah say simplest possible instruction like the knob instruction so that requires the one complete machine cycle so one machine second other fetch cycle that is the four t state and four t state ah you so you cannot have a delay of one t state in that processor so that is the problem so you need some external timer or counter chip to be connected to the processor so if you really want some precise timing so ah for a system operation so these are the things that we should have now ah what is done in eight zero in the microcontrollers is that all these components they are put onto a single chip so what are the advantage advantages are like this that first of all ah the overall system size becomes small so instead of having single ah separate chips mounted on a board now in a single chip you have got all these components so overall size of the system becomes smaller second important thing is about the speed like when you have got the different components mounted on a printed circuit board so between them the connection is the ah the copper line ok so copper line connection systems they are external to the chip so they will be much slower compared to the on chip that is within the chip if i have connection so that ah compared to that this off chip connections are going to be slower so if you are looking for the speed enhancement so it is better that all these components ah be put into the same silicon chip ok and that is exactly what is happening in microcontroller that all these components they are put onto a single chip however so you cannot put the resources to a very large value otherwise the size of the chip will become very very large the footprint of the chip will become large so ah eight zero five one it has got four kilobytes of internal rom so you can program this eight zero five one to load some ah program on to this rom ok so that is that that is the internal rom then the ram space is really small one twenty eight bytes only and you will see that it is multiplexed in different ways also of course you can connect external ah rom and ram chips to the microcontroller to extend the total available memory that will see ah but internally it is like that so if your system is very simple it may be that with 4 kilobyte of internal rom and 128 bytes of ram so we can realize the system for example if you are implementing a traffic light controller so it may be possible that the system is very simple and we can do it with a single eight zero five one microcontroller instead of instead of having separate ram and rom chips on to the board four ah eight bit i o ports have been provided so that helps ah that is a large number so 8 bit into 4 that is total 32 bit i o that the processor can support ok without any additional hardware then 2 16 bit timers counters are there so we can so that can do some precise timing calculations so you can you can control the timing and you can also count some event that has occurred externally so how many say if you are measuring if you are counting the items passing on a conveyor belt so passing of every component or every item may be sending a pulse to the counter and accordingly the counter will find out we will count the how many such items have passed and serial interface so this is useful for doing some serial communication to ah other devices so if you look into the internal block diagram of eight zero five one so as we have said that on a bus so these are the components that are hanging so we have got 4 kilobytes of rom 128 bytes of ram 4 i o ports 1 serial port there are 2 timers timer 1 and timer 2 and we have got this bus control so bus control will be controlling the operation there the processing unit which will be doing the processing so ah when we are discussing about the microprocessors actually we discussed about this cpu only assuming this that this rom ram timers i o ports and serial comma serial communication was also made part of cpu but most of the components are outside but in case of microcontroller all of them are together so in the we have got this cpu then the interrupt con interrupt control and the oscillator that will be generating the clock signal so that will be coming from the that will be controlling the cpu so this is the internal block diagram of eight zero five one other features that we have in eight zero five one is the only one on chip oscillator so that is external only one ah oscillator is there for the clock generation six interrupt sources so we have got ah this external interrupt so there are two external interrupts and there are three internal interrupts in terms of that reset serial input output and the timers ok so two timers one serial input output and the reset so these are the six interrupt sources that we have then we have got sixty four kilo byte of external code space ok so that is for the program memory so this is ah so internally we have got ah internally we have got 4 kilobyte so you have got 4 kilobyte of rom so if you are connecting external memory so you can go up to 64 kilobyte of external space external rom for the data memory part so it is again another 64 kilobyte of external data memory so code memory and data memory if you take it separately so it is 64 plus 64 total 128 ah kilobyte of memory that you can connect to the eight zero five one system out of that half of it will be program memory half of it will be data memory in many realizations what we do is that we merge this code and data memory together and we get ah only 64 kilobyte as the external memory so which can be configured both as data memory and program memory so that may be useful in many applications now when you are the act using this external memory external code memory so there is a strobe which is known as the program store in enable or psn so this ah psen bit so that this particular bit so it will be controlling the ah read operation on the other hand for the data memory access so we have got this read and write so in case of ah normal processor or eight zero eight five we have seen that whenever we are trying to access outside the the memory so there were read and control read and write controls so for rom access only the read line should be connected to the read of the rom for the ram access the read and write lines are to be connected to the read and write pins of the ram but in case of eight zero five one since program memory and data memory are totally separate ok so the program memory is controlled by this psn signal psen signal whereas the data memory is controlled by read and write signal so when the eight zero five one is accessing ah is accessing ah program code so it will not activate this read read and write signal so we have to be careful in our design because then it will be through the the stroke given will be on the ah this program store enable line on the other hand when it is doing the read access or if data access so it will be activating only the read and write lines not the ah psen line so we have no so that way we have to be careful and this code memory is selectable by this ea external axis so whether as we said that there is 4 kilobyte of external memory so you can so you can at any point of time you can say whether you want to access external memory or internal memory so that way you can have this ea so this external access there is a pin that you can configure and you can set it to ah 0 or 1 accordingly you are the instruction will access internal memory or external memory for code access and we can as we as i have already said that we may have external memory as both data and code so that is possible so why this eight zero five one all on a sudden came so this this has come because of the new type of systems that we have they are known as embedded systems so an embedded system it is closely integrated with the main system and it ah so this m so it may be that in the overall system this embedded system is a part for example ah the say the washing machine so washing machine has got ah the interfaces which are to the outside world so they will see a set of buttons but internally there are computations like when the drum is rotated for how many turns it will be rotated what will be the temperature and it will sense the water level and all that so all those are done by the done by the embedded system or when you are driving a car there are many processors who are which are controlling different operations starting from this steering fuel injection anti brake then then the this breaking system ah this air bags then we have got power windows and all that so all of them are ah processors are there who are doing this competition but from the users point of view so we do not see those processors so we just see the overall system so that these are the examples of embedded system so this processors they may not directly interact with the ah environment they may be interacting with the ah with the with with the over the system into which it is put into so it is or it is a part of a bigger system so it may be interacting with the bigger system typical example is a car ignition control ok so that is so that as i have already said there are many such processors in the ah in the car in a car that will be that will help in running driving the car and its control so ah an embedded product uses microprocessor microcontroller to do one task only so the task is fixed like when you are driving a car so the operations that this processors need to do that is fixed ok so the on a car processor i will not try to say run a program which will find the roots of a quadratic equation so not do that but the processor is doing other things like this fuel injection steering control and all that so those are being done so ah they are doing only one task at a time so ah if you are using microprocessor as i have said that ok the size of the system may become large so as a result we are doing some we are putting microcontrollers and since we are doing only a single application or only a small set of applications on a on a microcontroller based system or an embedded system so we know the programs that we need to execute so we can burn those program to the rom directly so unlike a general system where different users may come up with different programs so we need to load that programs on to ram and from there we need to execute but for an embedded application the programs are fixed ok so that so we we can just lower we can burn those programs on to the rom so that this programs those only those programs will be executed by the processor so that is the point where this eight zero five one may be useful typical examples of embedded system like keyboard printer video game game player mp3 music players so embedded monitors mobile phones cameras ok so automotive control so all these are different examples of embedded systems so they have got this processors ah built into it now how do you choose a microcontroller like as i have said that there are several microcontrollers available in the market and in fact eight zero five one also there are variants ok so we have got eight zero three one we have got eight zero five two like that and their capacities are varying like ah eight zero three one will not have any internal rom eight zero five two will have one more timer in it so that way the ah the features will ah vary so which one to take ok so so for the criteria for choosing a microcontroller is first of all the meeting the computing needs of the task efficiently and cost effectively so speed should match the amount of the speed of the processor should match my requirement because most of the time this embedded applications that we have so they are real time in nature so so that the the task has to be completed within some fixed amount of time so the processor is slow so will not be able to complete the task within the reasonable amount of time so the speed of the processor is one parameter then the amount of rom and ram that we have in the system if the rom is small and my application have program size is large then i need to connect external memory to the chip ok that way the footprint ah will go up ok so we can have if we if we go for a higher family of microcontroller then possibly my program will fit into the rom that is available there and will be able to ah comp hold that task within the microcontroller itself and the ram also like how much of data that we need to store ok the basically the temporary data that we have so how much of those temporary data that we need to store for example eight zero five one it has got only one twenty eight bytes of ram internal ram so if you need more ram space then you have to connect external ram chip so how is it so are we going to do that so if my ah if we find that going to the next higher family so i can manage the ram space ah the variables then possibly that is fine number of i o ports like we can have eight zero five one it has got thirty two io bits ah four io ports and so if that is sufficient then it is ok if it is not we have to go for the higher one the timers number of timers that we have so each timer may be dedicated for controlling one operation so if you need precise timing for say more than two operation then possibly and they are paired parallelly so then possibly we cannot ah go for eight zero five one then size of the system its packaging its power consumption so they all will contribute to the choice of the microcontroller second important thing is the upgradation so today we are using some microcontroller so tomorrow we we can we can we go to the next higher microcontroller in my system as a result the system performance will be enhanced and but at the same time i do not want to change the hardware that we have ah too much ok so the pin configuration and this thing so the software compatibility so they should be there so they it should be easy to upgrade and the cost per unit so when you are when you have built a system based on a microcontroller then every unit that you sell the microcontroller price will come into ah picture so if the cost per unit is not low then the cost of the system may get dominated by the cost of the microcontroller so that way we have to be careful second important thing that we have is the availability of software development tools now as some time back i have said that that there are so many microprocessors and microcontrollers that you possibly cannot learn about the assembly language programming of all those all those processors so it is desirable that we can write our program our control program in some high level language like say c and then the compiler should be there which will translate this c code into the machine code of the ah processor so this assemblers debuggers compilers emulator simulator technical supports all these should be available for the microcontroller that we take wide availability it should be widely available and there is the reliable sources for the microcontroller so they should have the these easily easy availability you can say ok and it is available in large amounts so these are the criteria that will guide us to choose the microcontroller so as you can see that some of these decisions are based on the electronics that we have like this speed amount or rom ram etcetera but many of them are economic also like say availability of availability and of reliable resource sources and all that so they are not there and similarly the development platform so they they do not ah that is not again the part of the basic hardware so they are the additional things that are done by the vendor to promote the product so that the developers can use those platform to ah develop product on ah or develop applications on that product so that way you see that many decisions are not ah done based on solely based on the quality of the processor but the quality of other things as well if you look into this eight zero five one family then ah this this rom type so eight zero three one it does not have any rom eight zero five one eight zero five two then eight seven five one eight seven five two eight eight zero five one they have got mask long eight zero ah eight seven five one they have got eprom so they are electrically programmable rom and ah so and then we have got flash e prompt in eight nine series so eight nine series has got so many processors and they have got they have got e e from electrically erasable ah programmable read only memory so we have so these are some of the examples that you see so this first ah two words so they will tell the manufacturer the a t stands for atmel c stands for the technology the cmos technology and lv is the low power version ok so the supply voltage is low 3.0 volt whereas the normal processor the supply voltage will be 5 volt so ah this way there are many vendors of this 8051 series of processors and accordingly you can find out the [Music] you can find you can see the series number there so if you try to compare across this family members so this we are just comparing the eight nine series so eight nine five one which is basically the eight zero five one only so it is four kilo byte of ram rom one twenty eight bytes of ram two timers six interrupt sources and thirty two io pins eight nine five two or eight zero five two it has got eight kilo bytes of rom two fifty six bytes of ram so you see the rom and ram have been doubled then timer is also one more interrupt sources are also two more io pin remains same eight nine five three so they they are the rom size is increasing further so you see that we have got many choices ok so we have got many choices so based on the application that we have we can we can go for um additional the higher family of processor and this one ah this eight nine one zero five one and eight nine two zero five one so they have got some additional things like watch dog timer so they are ah useful when you are when you have got some deadlines for tasks and you want to detect whether ah the task has missed its deadline or not so for those type of applications so we need this watchdog timers so then the analog comparator so analog voltage comparator then the in system programmable that is when the the system is operating so can you change the program so those ah series so the ac is marked as ac so they have got this features so naturally the better processors we have got better flexibility facilities but the cost of the system will also go up so this is the overall ah diagram that we have so we will explain it by parts ok so so in the schematic so this is a better view of the processor so you can see that ok we have i said that there are 4 ports so this is p 0 p 1 p 2 and p 3. so these are the 4 ports that we have and ah they are all eight bit ports then we have got this ah rst which is the reset ok then there is ea bar external access so these the so they are actually this rst and ea bar so they are coming to the ah chip so they are input to the chip it is not shown here explicitly so this so this ah a bar so if this line is made 0 that means the the system designer wants that the 8051 should use the code space from the external memory it should take the code from the external memory external rom and for normal operation we should set this set this e a bar p into one so if this pin is made high then ah the eight zero five one when it is accessing code it will be using the internal ram internal rom and we have got this so many of this pins so they are multiplex like you see that this p 0 for the port 0 the bit so these pins have pin number 32 to 39 so they act as the port pin as well as the multiplexed address data bus ad 0 through 87. so here also like 8085 the bus is multiplexed so we have got this lower order address bus and data bus multiplexed ad 0 to 87 then if you look into port 2 here also you see that the ah it is the the pins they are multifunctional pin and it they can they will act as i o pin as well as the higher order address bus so if you are connecting some external memory then this ah 8 so this all these pins 21 to 28 and 20 20 32 to 39 so they will be used by the external database external address and data bus so you cannot use those ports for ah io device ah for io operation ok similarly if you look into this port 3 you will find that these pins are also multiplex that is pin number the pin number 17 its it acts as the bit seven of port p three as well as the read bar signal so when if you are connecting external memory then this read bar right bar lines are required and then you cannot use this port 3 as the port for accessing as port bits ok so all these are there similarly this [Music] 3.0 is used for received data and 3.1 is used for transmit data so this is these are for serial communication like we have got s i d and s o d in case of eighty eighty five so here we have got t x d and r x d then these are the two interrupts that we have from outside int zero and int one then this t zero and t 1. so they are for the counter operation of the timers ok and then this ale is same as that we have in 8085 and psn bar so this is for the external memory access the you can give the ah you can connect to the ah read power pin of the rom ok then we have got the crystals