 In today's class, we will start continuing further our discussion on microcontroller architecture and programming details. So let us begin with the programming philosophy. As we discussed in the last class also, this philosophy would center around registers. So we have seen that there are different levels of programming and each one has different ways to access different registers in the microcontroller platform. And these registers are basically at their fundamental level, they are flip flops. So you can see hardware has these different layers. One can understand the hardware in different kind of layers and one can understand the software also will have like as we will see now, different levels of programming. So the base level is the assembly language where you can access each of the registers by directly assembly language. And we will see how do you do that with some examples of some of the hardware of basic fundamental microprocessor 8085 system. And then like we will move on to like more advanced system and see some examples of programming there. And like we will move to further advanced system which is an arm kind of a technology. We have seen in the last class in general philosophical kind of a description or you know motivation for which arm technology was developed and it has lot of usages in the modern kind of programming systems. So that is why like it is good to kind of study arm kind of a technology and its applications or its interfaces that it provides and things like that. So that you are in this way you will be able to develop your own mechatonic products in the future if need be very easy. And you know like what is the state of the art that is happening. So that is why we will work with this Tiba microprocessor and that Tiba microprocessor will give us lot of understanding about arm technology. Okay, let me make it full screen here, so that, okay. Now we will move on to little bit more details about programming. So if you go to basic fundamental assembly level language say 8085 system, the programming would have like know this something called opcode, okay, which is an instruction for like know as in C you have some instructions like that you will have some instructions in the assembly level programming which is like given in some kind of MOV, ADD like you know these are kind of like very short kind of instructions are there. This MOV as the name suggests it moves like contents of register A register C, okay. Results A and C as we saw are registers in architecture of 8085 system somewhere. So A is a special register called accumulator in that system. So these are descriptions of these all things will be given in the data sheet, okay. And even these commands and their meaning will be given in the instruction manual for the microprocessor in this case. So this is most fundamental kind of a level programming that one can do where like know you actually write assembly language code. Nobody does that these days actually this is just for the sake of like academic understanding that you look finally whenever we assemble our C code you know it finally gets into this kind of a program and this program gets executed in its own way. So finally each of these commands also will have some kind of a hex code associated with that, okay. So that is how like you know that code will be loaded into the respective registers and then like know based on the timing and control circuitry that one by one like no lines of the codes will get executed and that is how like you know your operation happens. So this is both most fundamental level kind of understanding of how things happen at the hardware level. Say for example when I say moves contents of register A to register C there are some kind of hardware pins to be enabled and then like they may need to be made high so that contents of the register A are available on the data bus and then like you know you enable some other pins so that the contents from the data bus are transferred to register C. So these are kind of like you know micro instructions which will be associated with each of these so called like you know of code okay and number of these micro instructions will determine how much time would take how many clock cycles in particular would be required to execute this command move here okay so that is like understanding here so for any command. So let me switch to this window about instruction set and in the instruction set you can observe now that there are this many different instruction that will be given okay so for example like know this is instruction ACI okay so its description is add immediate to accumulator with carry. This accumulator is this register A so like so if you have no understanding of architecture then these commands will not make much sense but if you have understanding that okay oh look this is a accumulator okay and this command has this opcode and operand and then like you know number of time state it takes is 7 or t states cycle number of cycles of the clock it will take to execute this command is 7 here like that this this all these details will be given and this instruction has hex code this C is 57 so so olden days you don't have this like the computer or keyboard to kind of program this 8085 system so what you do is like know you have this like a LED display in which there are only like eight fields okay so four or six are there are only six fields there are four of them are address field and like two or two of them will be data field so you start at any address and you start kind of coding like know these hex codes into into these different and memory locations and that's how I know you start writing the writing the program so which was quite cumbersome to kind of clean like we have done that like in our micro processor course or lab that I was when I was my mtxt20 year I did that in one of the labs actually so it is quite quite a time-consuming process also in my BTEC project I did that actually so so it's it's very interesting like now if I think about like how these kind of you know so much of a treasury to kind of like code this and then make sure that they execute properly and raise your motors or any other applications okay so so this is a manual I'll post these also to moodle so it will have like all the instructions that are available for 8085 system to go they'll be all there in this so there are some conditional instructions unconditional call will be there there will be some if I statements like no how do they execute techno that will get to know say for call on positive so so if something is positive then like you'll shift the you know address next address which will be from where the program execution will be the restart like that you'll have some kind of a nesting loops possibility and things like that okay by using this basic fundamental level commands so nowadays all the modern microcontrollers you just say like if else like no in C language and like your job will be done but in olden days like there is no command if you'll find in this whole set of instructions for this there is no command if or there is no command while so there are these commands called call on positive call on carry or call on zero no so that means like when the flag you have seen the flag register in the last class when that flag in the zero flag in that flag register becomes one then like no the the program some subroutine will be called for the for the and that's how this is instruction words actually okay call okay so this is how like olden days like this is programming used to be and that is what is done now also but it's only like you know all the compilers will do that treasury okay so human beings are spared from from that so like no so so we as the programmers for hardware programming right all the codes in in C language and they get executed okay so that's how things happen there hmm so clear this part okay so far good so main understanding here is that this 8085 system or any micro control system will ultimately have the program in the assembly language that will be downloaded to micro controller and each of these instructions of course they will have associated some kind of a hex code with that and given like no higher level program okay that you'll write in C the assembler okay will or compiler will compile this program and like no generate these of course and then like no generator code which will be only with respect to this of course and that is a code which will be downloaded the micro controller that's how the things are going to happen and you'll see later okay when we see the interface of diva micro controller we'll be able to see that some of these opcodes or some of the assembly level parts of the code which are there in the in the micro controller okay so so we'll do that now let's look at this system again um these are the fundamental operations uh that will happen in in micro controller at of i mean at the assembly level okay so so all these these operations are like you know that way the universal i would say uh but one can see there are some kind of a opcodes or instruction sets which are in the assembly level for each of these you know fundamental operations okay there are some logical operation there are arithmetic operation we saw this command add okay then internal data transfer we saw this command movie so like that there are these you know branching operation there is call command or jump or jump on carry jump on zero you know these are kind of commands which are uh for branching okay so you are executing some series uh the commands and from here now uh based on some condition i want to execute something else i'll jump from there to something else execute that and come back and let me keep doing that that way you'll have a facility to create loops and create if else statements and things like that as i said okay so these are the uh the ways in which things actually happen at the assembly level so we don't need to get into a whole lot of details here but we need to have this sense that okay oh look whatever commands i'm writing here in the higher level language they'll have compiler will actually compile them and convert them into these opcodes and and then those of course will be finally executed for the microcontroller now let's move further for a little bit higher level microcontroller so uh if you see your i don't know microcontroller or your uh xcp100 their philosophy is i mean philosophy is the same like you know you need to have a finally convert that codes into the the assembly level language but um to access the registers okay you don't have these registered names a b c d as you had in the 8085 kind of a system okay you'll have these registers access there in in in a different way okay so these registers are available as a variables in c okay some variable in c these variables would be defined in the in the data sheet of the microcontroller and also they'll have header files provided to you in which those registers are mapped into those variables are mapped into certain kind of memory locations or registers finally okay so when you write to that variable it will go to appropriate register in the microcontroller system okay that data value whatever you have written in that variable it will go to that particular register and there are two types of uh such registers one is control register and other is working register uh control registers for any interface okay there will be these two kind of uh uh uh registers uh so we'll see some examples say for example maybe we can okay maybe we'll i'll explain first what this function is and then we'll take a take an example uh so control registers set up your interface for particular or configures your interface for particular operation to happen and working register actually supply the working values which will be continuously changing so control registers you set up only once in your program okay and then working register you may keep on changing based on like you know whatever um closed loop operation that you are carrying out for example uh if you remember or some of you might have already uh done this programming of xcp100 in that this ddra register was there ddra variable was defined okay so the call is ddra now register only although it is a variable in c you you you like because this is mapped to a certain register which is fixed in the computer or microcontroller memory uh it can be referred to as like no ddra register okay so say this register ddra in digital input output interface in xcp100 okay it controls as is the the name suggests direction definition register okay so ddr is direction definition register okay so it defines the direction for the data transfer in this uh register pins of register a okay and this a is a port that is available uh on the hardware pins of this microcontroller uh so uh this all will be given in the in the data sheet okay we'll look at this xcp100 data sheet also in a minute um but this ddra that way happens to be a controlled register then you don't keep on changing like you know the data directions in the typically in the register so once you define okay oh i'm uh using this register as an output register and the pins are connected to some output leds i won't kind of like me change the direction now okay once it is set we will execute that for say some some uh display of some numbers or or dancing leds or some led to glow for to to indicate some operation happening okay that is a kind of a um uh functionality that will be built into the into the microcontroller program okay so so that way this ddra register is a control register now control register will just like know set up the things okay it will not put values into any of the you know functions actually so that for that you need the working registers so these working registers will actually start putting values in that and outputting something with that you want to execute in your um final program okay so so for example uh ddra will set this register to kind of have output kind of a definition for pins of port a and uh you actually write to this port a some data and then like that data will be displayed if it is output port that is how like now you have written this program so we'll see that now in a data sheet of a of this microcontroller okay so let's switch to that so this is xcp100 reference manual now if you see this manual it will have 13 24 pages okay so we don't get into like no reading all this manual to kind of start putting programming so we want like no see this for the module that is uh responsible for actually doing this data input output it's this port integration module and we can directly go to see what is there in that module okay and you can see that you can read through some of these details as his port a port b something are given then like no there are these different variables will be given then the number of pin definitions will be given like that all these things are given okay so you can if you know this uh uh name of some registers you can look for those registers okay as they you can say control find and look for these registers okay uh it taking time anyway yeah so I say okay here ddr a and I get all the details about this register okay so you can see here yeah so this is data register ddr a data direction register okay for port a okay so now uh it gives me all the definitions okay if the value is written there it will be defined as input port or output port like that it it uh gives all the description and according to what is written in the data sheet if I uh set up this register some number uh then like no accordingly the functions will start happening in the hardware okay so that's how like uh one one goes about programming these different different uh microcontroller interfaces so this is like about uh this simple digital input output interface okay these are like you know many different uh you have ddr bdd or c and things like that or then you'll have a port register port a port b port c is a data register so port a when you say like the the data will be given to this port uh or like you know read from this port okay port c means the data will be it suppose I want to write or this is port is output port I'll write this uh output number into this port and like uh depending upon now what is the data say that data is one zero one zero one zero then wherever that one is there that led will load okay zero is there led will be shut off or something like that so so you you are putting like no hardware pin high and low values uh on the hardware pin by by putting this data into respective registers and that is the operation that takes place in the in the input output kind of ports okay so this is how uh we we look for like you know programming for uh little higher level uh microcontrollers okay so uh this kind of a thing you'll be able to observe for many different kind of uh interfaces okay so these different different modules so on this like you see different chapters in the data sheet you'll find what are modules that are provided by this microcontroller uh or in the data sheet you'll find all these modules that are provided and more details of those uh interfaces will be observed in the in the respective chapters of the data sheet okay so uh we move on to now uh the next uh part okay so typical interfaces will be of uh these different different kinds okay so uh depending upon microcontroller that you choose you'll have these different interfaces and interfaces names also will change from one microcontroller to other microcontroller say for example this digital input output interface as we saw just now in xcp it is uh called port integration module or pim in the tiva it has a name gpio okay or general purpose input outputs so like that you'll have different different names in different microcontrollers so don't get bogged up with that you can just understand okay this is your interface that you won't need to program okay uh typically for mechatronic applications from sensors perspective we'll need these uh these interfaces general purpose like you know this is digital input outputs analog uh to divide digital conversion and then like you know quadrature encoder interfaces and maybe some serial or other communication modes uh can be possibility especially if the sensors give directly the output in terms of serial uh port output like a can interface then like you know you'll need these uh serial or other kind of communication modules to be programmed actuator typically will will run by pwm modules uh in some cases there is a possibility of running the actuator by using uh this digital analog conversion also but in most of our cases it it it may not happen uh okay so I think maybe now we will just uh uh talk about little bit more details of these interfaces but we'll come back maybe in the in the next class so that you have this small chunk of thing about just maybe base fundamentals of these and then we can come back to these more details of these interfaces uh in the next part of the today's class okay so I'll stop here for now