Delve into EPWM Modules with DSP Coding

Lecture: 6

Estimated read time: 1:20

    Summary

    The lecture delves into the intricacies of setting up and understanding the Enhanced Pulse Width Modulator (EPWM) module, vital for controlling signals in embedded systems. Throughout the session, the instructor, from DSP Coding, explains various components essential for PWM signal generation, including types of counters, the role of registers, and the significance of synchronization logic. The lecture emphasizes how to set up different modules using Code Composer Studio (CCS) and MATLAB, focusing on practical steps like phase-shift enabling and interfacing with hardware.

      Highlights

      • Initiating EPWM setup with introduction to counters and timers.⏲️
      • Step-by-step instructions for configuring EPWM using CCS.📜
      • Discussion on synchronization logic to manage multiple modules.🔄
      • Operational details on generating PWM signals with specific frequency.⚙️
      • Hands-on demonstration with example codes in MATLAB and CCS.🖥️
      • Clarification on utilizing different GPIOs for PWM setup.🔌
      • Detailed walkthrough of key registers involved in EPWM.🔍

      Key Takeaways

      • Understanding of EPWM module for managing signals in embedded systems.🔧
      • Utilization of counters and timers in generating PWM signals.⏱️
      • Procedure to set up EPWM using Code Composer Studio and MATLAB.💻
      • Explanation of synchronization logic for multiple modules.🔄
      • Insight into adjusting duty cycles and frequency of PWM pulses.⚙️
      • Practical demonstration using real-time coding examples.👨‍💻

      Overview

      In this engaging lecture, DSP Coding dives into the essentials of setting up the Enhanced Pulse Width Modulator (EPWM) module, a critical component for managing digital signals in embedded systems. The focus is on utilizing various counters and timers to effectively generate PWM signals, using tools like Code Composer Studio and MATLAB for practical implementation.

        The instructor provides a detailed, step-by-step guide on initiating EPWM setup, covering essential topics like types of counters, synchronization logic, and the specific roles of key registers. This session also includes practical demonstrations, shedding light on real-time coding practices and hardware interfacing—critical skills for anyone delving into digital signal processing.

          Throughout the lecture, attention is given to the intricacies of synchronization between multiple EPWM modules and adjusting PWM frequencies and duty cycles. By exploring these complex topics through an interactive, example-driven approach, the session equips learners with the essential skills needed to manage and control PWM signals efficiently.

            Chapters

            • 00:00 - 01:00: Introduction to the Lecture The introduction sets the stage for the lecture, providing an overview of the main topics to be discussed. It outlines the objectives and key points that will be covered, preparing the audience for what to expect and why it matters. The speaker also highlights the importance of engagement and participation, inviting questions and discussions to enrich the learning experience.
            • 01:00 - 30:00: Setting up and using CCS Studio In this chapter, we explore the setup and utilization of CCS (Code Composer Studio) Studio. The chapter provides a detailed walkthrough on the steps required to properly install and configure the CCS Studio environment, ensuring that users can effectively compile and debug their projects. Key features of CCS Studio are highlighted, alongside tips and best practices for maximizing productivity. Readers are guided through initial setup, configuration options, and troubleshooting common issues to ensure a smooth user experience.
            • 30:00 - 45:00: Introduction to Counters and Timers The chapter provides an introduction to the basic concepts of counters and timers. It begins with a practical instruction, suggesting the reader to 'go to that down arrow,' indicating a guide or tutorial format. Additional context from the transcript would likely elaborate on how to access, set up, or utilize counters and timers within a specific system or software application. The emphasis seems to be on a hands-on approach to learning these tools, understanding their functionality, and how they can be applied to various tasks.
            • 45:00 - 60:00: PWM Modules Chapter introduces PWM (Pulse Width Modulation) modules and their functions.
            • 60:00 - 75:00: Generating PWM Signals The chapter titled 'Generating PWM Signals' discusses the process of generating Pulse Width Modulation (PWM) signals. During the session, there is a mention of clarifying doubts, indicating that it is an interactive session. Participants are encouraged to communicate; however, they are also asked to mute their microphones to maintain the session's order. The process involves practical examples, specifically referencing 'bit field and cpu one' as examples to consider. This indicates that hands-on examples or exercises are integral to the learning process of this chapter. Overall, the chapter combines theoretical concepts with practical exercises to facilitate a comprehensive understanding of PWM signal generation.

            Lecture: 6 Transcription

            • 00:00 - 00:30
            • 00:30 - 01:00 me
            • 01:00 - 01:30 okay uh so you go to that down arrow now
            • 01:30 - 02:00 click on english
            • 02:00 - 02:30 you can clarify that doubt in this session okay oh yes sure everyone will get it yeah yeah sure i'll say that you just turn off your mic okay examples go to examples and then bit field and cpu one okay now you import any of one of the
            • 02:30 - 03:00 example just imported now you go to that particular project here down arrow click on main file you double click on it yeah what you do is you press that build
            • 03:00 - 03:30 button [Music] there is the build button yeah yeah and now you can press that debug button okay it is building let it get built yeah it's fine now you can give up with
            • 03:30 - 04:00 that button yeah just click on that yeah okay yeah i think it's fine part it's working fine okay
            • 04:00 - 04:30 yeah you can click on green button now the green button which is the resume button can you see just below the view tab there is one green button just below the view tab yeah yeah yeah yeah now your code is running yes you don't have to do anything extra okay already there is one uh connection file
            • 04:30 - 05:00 and everything is there so so you don't have to do anything next time you're okay connection file in the sense that target configuration file is there now okay yeah yeah so it's already there okay so the board is already selected maybe somebody has used this book immediately it's already there active by default okay so you don't have to change anything in there okay yeah so you can stop presenting for okay
            • 05:00 - 05:30 okay i'll start to visit present on to this microcontroller and then we saw gpio and peripheral maxi like uh what gpios we can use onto the board and how can we assign it to particular peripheral that we saw like from here we saw when max value is set to 0 it is particularly a gpio open and if it is set to 1 it will be a pwm pin so the max is divided into two
            • 05:30 - 06:00 categories as we saw yesterday that is normal marks and gmax and then we looked at the interrupt that how core interrupt is processing with the help of ifr ier and int google global switch so we looked at this logic after that we saw how to program particular register in order to you know enable and disable it and we saw how to you know trigger an interrupt with the help of peripheral interrupt expansion modeling which is basically with the help of pi assignment table or pi vector
            • 06:00 - 06:30 table so from this pi vector table with the help of group and subgroups we used to trigger a particular interrupt and then we used to perform any operation if we want to perform we saw an example of cpu timer yesterday where we used to configure cpu timer at particular interrupt a particular interval of time in order to trigger an interrupt and then we wrote a certain set of code over there that is to toggle a particular gpio which was assigned as a blue or red led and that's how we executed a code so we saw
            • 06:30 - 07:00 a basic background of this and looking into the software and looking into the software so we saw the that file is how to create a new project from this particular file how to import any existing files if it is there in your workspace then how to add new header files into a project like if you right click any of the project and if you go on
            • 07:00 - 07:30 it's a little bit handy so it's working little slow as my matlab is also open so we saw how to create any particular new project with respect to this particular software then we saw how to debug your code and as well as we saw how to import your example from resource explorer as well then
            • 07:30 - 08:00 then we saw how to use these expressions variables and resistors so we basically put our all things into this variables column in which we used to see what is the output of your algorithm and we as well saw about c2000 there how to import your project from c2000 there okay now in today's session uh i'll explain a little bit about matlab as well like if you want to install this particular package into matlab what you have to do so for installing a package into matlab you have to go to add ones
            • 08:00 - 08:30 from your matlab window and then you have to click on get hardware support packages so if you click this tab uh another window will open which will ask you which package to add it will take some time so whether you are using 1920 or 21 matlab okay all the ccs version below nine will be uh we actually are supported over here uh 11 i guess it might support you can try once so in the search add-ons button you can
            • 08:30 - 09:00 click on you can just search for c2000 and after that this is embedded coder support package for texas instrument c2000 processor you can download it from here if you click this okay it will ask your install i have already installed it so it is asking me manage so after installing it something like manage will come if you click on manage you just have to select the board which you are using and all and it will get connected to your this particular matlab so you will as well get one youtube video as well if
            • 09:00 - 09:30 you see how to connect your microcontroller to this particular c2000 processor so this is the basic procedure it will not take as hard okay so you just have to manage and then you have to if that software is installed it will show something like this yeah it will show something like this so you can go to setup after clicking on setup uh since i have already done each and
            • 09:30 - 10:00 every setup i don't know what next it will show but i guess it will show only settings whatever you want to do in any system matlab works little bit slow if your processor is higher then it may work little bit fast as well since i'm using i3 little slower so yeah select processor family this will the atta a new tab will come like this
            • 10:00 - 10:30 so from here you have to click on only ti delfino f3 790 all the other boxes you have to uncheck and then you can click on next and then you can set up i have already set up so i don't want to repeat the procedure over here as it may cause any more operation when i'm explaining the code since these are very sensitive connections once you have done you don't have to touch anything of this okay so once you click on next you will get certain things over there in which you have to specify the location of your ccs that
            • 10:30 - 11:00 you can browse and specify and then it will finish so it's a very easy procedure if you have to install your cc studio into this one particularly and if you want to see how a code is running onto this particular thing you can go to simulink and i'll explain certain settings that you need to do before dumping any code so matlab is very easy and you will get lots of resources as matlab is a widely
            • 11:00 - 11:30 used software so you will get everywhere whatever you want to have any interface with that we'll see about epw module today in brief
            • 11:30 - 12:00 mostly i'll try to cover it in the less period of time and i would also like to watch one video after that so that it will be totally clear to you what exactly a pwm is so it is taking some time we'll wait till then
            • 12:00 - 12:30 so before so till that time what i would like to tell you is this is also running slow because of matlab so i have to press close matlab before explaining anything so let's just deal with the matlab first you try to install uh c2000 wear package
            • 12:30 - 13:00 into your matlab you try to integrate your board once your hardware board arrives for you if your vendor supplies it early it will be very nice uh even if he doesn't give you right now there is no issue what will what will do is this group will be active uh even if the workshop gets over so that even if you have any doubts you can ask me any time and if i'm if that doubt is within my reach i'll try to help you so it is not necessary that you have to
            • 13:00 - 13:30 watch the videos and then only ask me okay after some time also after some duration also you can ask me whenever you get time you kindly go through all the videos and learn how to make your own code into this as you are all aware of how to trigger an interrupt now is there any doubt with all the interrupts that have explained till now to anybody shankar
            • 13:30 - 14:00 do you have any doubts i guess he's not here okay so i'm not in a position to say that i have a okay okay have you not watched all the videos uh sir i had attended the session but yesterday i was doing some work in parallel as well okay hopefully watch again okay okay fine no we shouldn't
            • 14:00 - 14:30 i hope videos are understandable to you yes yes yes they are understandable right okay okay fine so uh muthu guys for me do you have any doubt till further till this session is there anything that you would like to ask okay i think he is also not here siddharth do you have any doubt no sir no doubt from my side also okay
            • 14:30 - 15:00 okay so if you face any issue regarding downloading or anything you can ask okay okay yeah one more thing i would like to tell you guys is once you watch all the videos and once you clear with the interrupt and everything you know it will be very easy for you that uh if you want to generate any logic for any code like you can think on your own how to you know generate any particular okay okay okay i got your message so i'm saying if you really want to you know think about this that you want to generate any particular
            • 15:00 - 15:30 code onto the something so you can as well do that is my matlab screen visible to you guys yes okay okay so okay okay so i will just uh import one of the model that i have created yesterday so
            • 15:30 - 16:00 if you go to model settings you have to wait till that model gets input okay creates the same problem click just hold down settings
            • 16:00 - 16:30 whenever is matlab or joined with any other css software it will work very slow
            • 16:30 - 17:00 we can work on only one system i did not know much about matlab frankly speaking so i have just watched some of the videos in order to explain to you guys
            • 17:00 - 17:30 as i have already i have been always working in ccs only so whatever my algorithms and everything i make i just make it in 6s only like you can see from here as well if i have to make code like sppwm for my inverter i will just do it here if i have to make any code for adc's anything i will just do it here even if motor codes are there for any bldc or any motor i will just take the examples and i'll try to do my code on my own so rspwm is also there it's a remote state
            • 17:30 - 18:00 pwm technique for inverter so we'll see how actually this pwm switch you can implement csvw cmd elimination is also there for dual to level inverter uh if somebody wants to say something sir earlier mentioned in the workshop that you know if we use through matlab it has to access the ccs package anyway so yeah what is the reason uh usually
            • 18:00 - 18:30 doing this through networking uh no actually some of the people wanted to know how to integrate the board to matlab as well because matlab is a kind of gui environment now it provides you more easy way in order to implement your algorithm because you just have blocks and you can connect them so it's a very easy way to implement your algorithm so that's why we are teaching this as it was not a part of course as well and i am not much aware about this as well but as per some request and other participants request i looked into it
            • 18:30 - 19:00 so basically if you go to uh this is one of the code that i saw and it includes two gpios this gpios i have taken from library browser so if you go to library browser in that particular library browser you will have a embedded coder support package from this embedded coder support package if you go to f2l 3790 which is our mode you can see here the gpio is listed as digital output so you can click on that and you can add it to your model
            • 19:00 - 19:30 so once you add it to your model and if you double click this uh it will open its own setting that which gpi you want to trigger and as per our presentation that we saw that our blue and red leds are particularly gpio number 31 and 34 blue is 31 and red is 34 so from this we are triggering both the leds so in this model i have taken gpio 31
            • 19:30 - 20:00 and i have clicked on toggle option as well and i have clicked on apply and okay next gpio a digital output have taken gpio 34 which is a red led this is blue led this is really great led so this code will blink these two leds i am giving one constant input from here setting sampling time as 0.5 and in signal attributes you have to just click on output data type as unsigned integer 16 bit data that is 0 to 2 to the power 16 values it can take
            • 20:00 - 20:30 then you can go to your hardware settings and in hardware settings you need to make some changes over here like if you're going to hardware implementation you need to select your board it's working little slow please have
            • 20:30 - 21:00 patience with me yeah so from here you can see we have already selected ti delfino f2 3790 board you have to select device vendor as texas instrument and device type as c2000 and after that in this math and data type if your code is not running or showing any error
            • 21:00 - 21:30 onto the flush to zero option you click on gradual underflow it's your simulation behavior basically so if any error is showing in your code you can go to gradual underflow instead of this flush to zero i don't have much idea what exactly this means so from this one you can just click ok and then there is one option over here that is build deploy and start so you can build your code and your led will start glowing so the
            • 21:30 - 22:00 basic example was to show that your both the leds will glow with this particular example if you try to do it you try to do it on your own in matlab once your board arrives and try to deploy the code after dumping this code will as you you'll see that both the red and blue leds will start blinking okay so since this is not expression of interest as of now i'm not dumping it as it will take more time so i'll just close it hope this was clear to everyone
            • 22:00 - 22:30 uh yeah okay so so today we will look into the epw module so before learning the epw model we need to have a basic understanding of what is counter and what is timer and how does they perform okay so just to have a basic introduction to counters i have i have shown here some slides to you
            • 22:30 - 23:00 that uh any counter is a combination of flip flop basically you must have studied flip flop like sr flip flop is there and jk flip flop is there so what does this flip-flops does is they store any particular bit like ones or zeros they can use to store this particular bit the combination of this flip flops are called as counters so counters are the circuits basically that transfer any particular uh bed or byte through particular number of states that how many depends on how many
            • 23:00 - 23:30 flip flops you're connecting so basically there are two types of counters one is a synchronous that is parallel counters and another one is synchronous sorry synchronous parallel counters asynchronous ripple counters okay so you don't need to understand many things into this what you need to just understand is a counter is something which is counting from certain value to the bit to which that counter is designed for let's say if it is a 8-bit counter it can count from 0 to 2 to the power 8. if it is a 3-bit counter
            • 23:30 - 24:00 it can count from 0 to 2-q that is 8. so counter can be counting from this particular values to any particular bit number which is for which it is set okay then you can see the difference between asynchronous and synchronous operation now synchronous operation every clock is fade to individual flip flops okay separately and in a synchronous counter kindly hold for a minute my laptop battery is getting low i'll just put a charger
            • 24:00 - 24:30 yeah so
            • 24:30 - 25:00 so we are talking about counters so saying about the basic operation of counters you can see a clock pulse okay here so you can see whenever a clock pulse is detected on its rising edge so these are
            • 25:00 - 25:30 the rising edge of any clock and these are the falling edge of any clock so whenever any rising edge is detected to any particular clock your counter will start counting from zero to that particular bit to which it is assigned to if it is a three bit counter made up of certain flip flops okay it will start counting from zero to two q that is it and the time period of each clock will be donated denoted by t clock so the basic need for understanding this counters operation is that there are
            • 25:30 - 26:00 certain timers and counters into this particular board peripherals which are used in order to generate any particular uh you know uh waves such as let's say such as if you want to generate any particular triangle waves or symmetrical triangle waves and if you assume that this tb clock is very small if it is very small i have shown here little bit big in order to make you understand but this time stamp is not very big it's very less so because of this you can assume this as a as a particular slant like of a wave you
            • 26:00 - 26:30 know a symmetrical wave so it will be rising from zero to eight in a slant way now if you see this is a one type of counter which is counting from zero to it and then it is gone to reset mode and then again it will start counting from zero to any particular rate so it goes step wise but since your clock frequency is very high your tv block basically will be very less and this tb clock which is actually the time period if it is very less you will assume you'll see that only a single slant wave will be over here not this step kind of waveform
            • 26:30 - 27:00 okay then there are two basic types of counters one is count up and down more in count of mode your counter will start incrementing from zero to seven if it is a three bit counter and your countdown mode your counter will start decrementing from seven to zero you don't need to understand many of the things in here it's a very simple logic okay we have to put our brains into designing algorithms whenever we are design designing it there are certain registers which are there for us and it is assigned for some operation
            • 27:00 - 27:30 so how can we use those resistors for our purpose that is our main aim okay so the basic operation of counters if you see from here that if i say it is up down counter it will count from 0 to 8 and then again it will count from 8 to 0 so this is up down counter example and in this counter you can see you can generate a triangular wave easily like if tb clock is very less your triangular wave will start from 0 up to certain value let's say 8 and from the 8 to 0 again so you
            • 27:30 - 28:00 can see a clear triangular waveform symmetrical waveform you can generate with respect to this particular counters so this is the use of any counter okay so there will be certain videos available if you want to understand how exactly they work and what is their operation but for this you just need to understand a counter is something which is counting from zero to certain bit to which it is assigned for then
            • 28:00 - 28:30 yeah so this was about the counters now yeah so this is our main module which we are going to learn about today which is a epw model so after explaining a little bit about this module i would also like to watch you one of the video on ti's website okay so first i'll explain here what exactly this is and then we'll see how exactly the pulses are generating
            • 28:30 - 29:00 with this model okay so first of all uh epw module is a highly programmable mode it is referred to as epwm and its full form is enhanced pulse width modulator module okay now epwm x here shows x particularly shows the epw module number like epwm one two three four five six if many modules are there it will show from zero one two three one two three two twelve twelve modules are there it will be pwm 12 like that okay
            • 29:00 - 29:30 then you have other two inputs from here that is a pwm syncing and epwm sync out now this sync in and sync out is provided in order to synchronize your multiple epw modules together let's say you have you will have be having two epw modules but you want both the pulses of ipw modules to start at the same time then you have certain buttons here like syncing and sync out that you can connect one to the previously and you can connect its output to the other one like you can see here x minus one x plus one it means if you are a tpwm two this
            • 29:30 - 30:00 will be pwm one and the lower version will be pwm three so pwm one two three will be connected together with this sync in and sync out option so syncing and sync out is basically to synchronize all the epwm modules together okay so this epw module has itself this synchronization logic and when this epw model has certain sub modules into it like counters and timers that we'll talk about in few minutes that will also have its own synchronization logic so we'll see how to synchronize those pwm as it is a main
            • 30:00 - 30:30 challenging task whenever you are going to implement any pwm however it's a very less instructions are required for that but in order to understand that particular thing it is important that you understand basics of counters and timers okay so from here i want to say that every epwm module has two outputs epwm xa epw xb and this epwm xa and xb where x denotes the number of epw module it is selected through gpio max how it is selected
            • 30:30 - 31:00 through gpio max we saw before that if in our gpio resistor if i am selecting any gpio pin and putting 0 in front of it it means that pin is assigned as general purpose input output pin but if let's say i put 1 in front of that particular register what will happen is that pin will be now assigned as epwma and which number of epwmp that we saw so from here if you see
            • 31:00 - 31:30 the dpwm4a is j8 pin number 80 which is which can be assigned as gp io 6 if you assign 0 to any gpio initialization and if you assign one then it will be selected as zpwm4 so you can see here all the pwm pins are in pair that is 4a4b 5f5b 6c6b then you have here 1a1b2a2b3a3b so epwm123 modules they'll be connected together then you have epwm456 so these
            • 31:30 - 32:00 modules will be connected together a basic logic for this connection i would like to show you from technical reference manual excel so
            • 32:00 - 32:30 i want to show you here this particular figure is visible to everybody yes okay so from here you can see your epwm one two three modules okay these are connected together now if you go for another thing it will be like epwm456 these modules are connected together so what it means is one two three are synchronized together
            • 32:30 - 33:00 okay now if you want to synchronize epwm3 to epwm4 there will be different procedure okay now if you want to synchronize epwm 6 to epm7 that will be different procedure so these modules are connected together like one two three four five six seven eight nine ten eleven and twelve so there will be total twelve epwm's available to you but now you will say that i just have here six epws how are you saying that there are 12 epidemics so as previously we saw
            • 33:00 - 33:30 like if you go to gpio and peripheral moxie so from this table you can see that 6a and 6b are available to gpio11 yeah it's fine but if you go to 7a and 7b epwm 7a and 7b from here you can see 3pwm7a and 7b are titled as gpio 12 and 13. so it means if your gpio 12 and 13 pins are available to you
            • 33:30 - 34:00 which is which i guess will be available to you you can see from here if gpio 12 and 13 is available to you you can use epwm particularly 7a and 7b as well so from here we can see gpio14 and 15 is available to yes and
            • 34:00 - 34:30 [Music] okay so from this gpio peripheral function here you can see 14 and 15 is available to us yeah so basically epwm 8a and 8b we can use so if you have six pwms it is not like you can limit you can be limited to six pwms you can as well use gpwm 18 and 8b then there are certain other vpwms also limited to epwm 12a and 12b that you can use from this table
            • 34:30 - 35:00 okay you can see if you are selecting your main marks like gmux as a one and you are selecting your normal mux as zero one you can as well select tpwm 11p and epwm 12a 12b as gpio21 22 and 23. so if you have your gpio 22 and 23 with you which you can see from here like gpr 19
            • 35:00 - 35:30 is available to you then from this one you can see okay that is not available to you so certain pins are available to you certain pins are not available to you so whatever pins are available to you that you can use yeah gpio19 and 18 is here from this one you can see j one pin number three and j one pin number four so for nineteen and eighteen
            • 35:30 - 36:00 19 and 18 you can see you can use epwm 10a and epwm 10b so there are certain epwm's like 88b 10810b that you can use irrespective of this pwms which are available to you that is up to 6a and 6b but for selection of this pwm you have to click on your gmax as one and you have to put your main mux as one so this will be setting configuration in order to initialize your 108 mb we will see how
            • 36:00 - 36:30 to initialize that through code as well okay so i'll explain that in code as well so so basically this was about pwm models available to you now the input to this pwm are through input crossbar epwm crossbar crossbar refers to something that is helpful for you in order to route your signals from one pin to another pin like let's say you have certain signal
            • 36:30 - 37:00 which is coming on to gpio 14 and you want to transfer that signal to gpio 15 you can use input crossbar so into the board if you want to transfer some signal you can use input crossbar then you have epwm crossbar like from normal gpios to epwf this crossbar will be routed so in order to transfer signal onto the board your crossbar is useful you'll see that as well through exercise how it is there and how you can use that so every module has its basic details
            • 37:00 - 37:30 okay and it is not in a brief way okay it is like you should understand it in elaborate way in order to understand each and every module or sub-module of this particular epw so the output of this pwm it can generate a start of conversion signal for adc adc is analog to digital converter and it is operated through a clock pulse only so that clock is nothing but a start of conversion signal so to generate that start of conversion signal you can use epwn now you're saying how
            • 37:30 - 38:00 now i'm seeing how you can use this let's say if you are generating certain pulse and it is having certain frequency of 10 megahertz and you want to have a sampling frequency of adc as 10 megahertz you can generate a pwm soc signal and you can use it as a sampling for your adc sampling frequency for your adc then adc will start sampling at 10 megawatts of frequency so when your adc is operating at a higher frequency your time for your isr to run like interrupt service routine that will be very less like one take 1 by 10 mega that will be
            • 38:00 - 38:30 time for your adc interrupt service routine to go and execute i hope you understood this i what i'm going to say by this is let's say you have a 20 megahertz of frequency of adc sampling frequency so 1 by 20 omega okay that will be around 5 nanoseconds so in that 5 nanosecond adc interrupt will be running like we saw in configure cpu timer instruction that i have explained to you previously that in 50 milliseconds you will be able to run any particular block of that cpu timer isr
            • 38:30 - 39:00 so that way adc isr is triggered after the certain period of time and that is your sampling frequency and in that adc isr that's why it is important that if your idc has a higher sampling frequency you can execute your code in less period of time so where you have to deal with the nanoseconds okay you want your sampling frequency to be much higher then people go for clas and all other features okay so you have cla over here that is
            • 39:00 - 39:30 peripheral interrupt expansion module cla so from this epwm you can as well generate an interrupt which can be a trip zone interrupt which is further given to pi module or cla module so what is a trip zone interrupt is let's say you want to employ any over current protection or over voltage protection into your board so in that case this strip zone is necessary like if you want to switch off your pwm at particular current or voltage this trip zone can provide you that feature by two
            • 39:30 - 40:00 particular categories that is one shot feature and cycle by cycle feature one short feature tells you that at one point of time when overshoot is occurring at that point of time your pwm signal will be off and cycle by cycle feature tells you that if you have prescribed some rating of the current and if that current particular rating is reached when your pwm is on automatically your pwm off will be assigned and once it has reached to certain lower limit automatically it will again start turning out just like
            • 40:00 - 40:30 in buck converter during turn on period and turn off period if you see your inductor current it will rise with certain slope and it will fall with certain slope so that slope you can define and you can you can use this strip zone for that particular thing so we'll see yeah sir are you referring to the current yeah yeah i'm referring to the peak current yeah so
            • 40:30 - 41:00 okay so this was about it so i'll tell you how to use tripzone as well okay and gpio will see how to initialize epwmas through gpio and we'll see how to generate a start of conversion signal to adc as well with the help of this ep download okay now from here you can see that i told you that this epwm has two outputs cpw and epwm b so these two particular outputs how you can generate the pulses of this
            • 41:00 - 41:30 output that we will see okay so this epwn module itself it has total eight number of submodules first is time based sub model another one is counter compare third one is action qualifier event trigger deadband pwm chopper rip zone and digital compare now you don't need to memorize everything in here okay what you need to understand is what are the resistors that used to program this time base of module counter comparison model and action qualifier sub model
            • 41:30 - 42:00 then this deadband pwm chopper trip zone these are the other soft models that will see one by one okay so first of all we'll see what is a time based sub model and what exactly it does so from this time waste sub module you can see that epwm syncing option and sync out option is connected over here as well so this time based off module will be present in each epm module like this is one epwm module particularly so like this there are 12 epw modules that we saw now and
            • 42:00 - 42:30 into this particular epw module these are the sub modules now there are certain functions or certain tasks that this sub modules are assigned to do okay like counter compare is there action qualifier is there this time based counter is there so into this time base uh module particularly this time base model particularly has its own counter okay so this time base sub module has a 16 bit counter what 16 bit counter means is it will be counting from 0 to 2 to the power 16 integer
            • 42:30 - 43:00 values so it means you can store the value in that particular resistor from 0 to 2 to the power 16 any integer okay now this time based sub module has its own clock okay see everything works on clock if you actually generalize your microcontroller is also working on a particular clock frequency right which is actually given through oscillator internal oscillator and then you have pll which is dividing your oscillator clock frequency and providing it to the
            • 43:00 - 43:30 other modules now epwm module of course if that model is working and so many sub modules are there it also needs to have its own clock clock is like a key to any particular device so once you put on your key to any particular device it will and you lose the key it will start working okay so it is like that so epwm clock is there for your epwm module but time based clock is there for your time based mode time based sub module so time based sub module has a 16 bit counter which
            • 43:30 - 44:00 has its own clock that is time based clock and this time base clock is a pre scaled version of your epwm clock now what is a pre-scaled version pre-scaled version in the sense a clock divider is present why clock divider is needed because suppose epwm is operating on 100 megahertz one epw module then all the time based module that is counter in here that cannot operate at the same frequency because you have to synchronize all the operation of all the
            • 44:00 - 44:30 modules so in order to do that this time based on module should work at a lesser clock frequency then your epwm clock mode and that's why here comes into the picture of clock pre-scale now epwm clock will not be also of 200 megahertz okay this epwm clock is also divided by certain clock prescaler which is actually faded from your main clock which is of 200 megahertz so that 200 megahertz will also have a clock prescaler and this that will give you
            • 44:30 - 45:00 your epwm clock so how to explain that if you go to your technical reference manual and from here if you go to epwm i'd like to show you one very important note
            • 45:00 - 45:30 from here you can see the type of model that we are studying is a type 4 type of epwm module okay and this type 4 type of epw module it has a clock divider okay and that clock divider that clock divider is actually your system clock divided by two it means if your system clock is of 200 megahertz and you are having a inbuilt clock divider which is of two two value
            • 45:30 - 46:00 then your epwm clock will be of 100 megahertz understood everybody so what i am trying to say here is that your epwm clock will be obtained from your main system clock and it is having a clock divider of 2 thus your epwm clock will be operating on 100 megahertz and your system clock was operating on 200 megahertz so this is how a clock divider works so you can see here this type 4 epw module it is it has a inbuilt divider which is
            • 46:00 - 46:30 actually divided by two so your clock will be operating on 100 mega so this is a very basic point that you need to remember okay so what i want to say is your operation will not be there at 200 megahertz when you are operating your board at 200 megawatts of clock but your epwm clock will be at much lesser frequency than that particular main clock now similarly your time base clock is there so this time based clock as well it is
            • 46:30 - 47:00 divided through a clock pre scale now the clock prescaler to this time base clock is divided into two register and that two resistor are main clock and high speed claw that is clock division and hsp clock division okay so that i'll explain how that is okay so that two registers which is main clock and hsp clock i'm talking about you can assign different value to this particular clock and you can set your time base clock okay so
            • 47:00 - 47:30 what is the default value of that particular resistors that also we'll talk about so before that you need to understand that clock whenever you are going to operate any counter or anything it will go on reducing okay it is not like your main counter will operate on 200 megahertz and your epwm is also operating on 200 megahertz that was the basic purpose to tell all these things over here after that this particular counter has a period register okay since this is a time based module this period register is called as a time based period
            • 47:30 - 48:00 since it is a time based counter it is called as a time based period now why it is called as a time based counter because it is based on your main clock it is based on your main clock timing so that's why they have named it as a time base counter now this time base counter has a period register which is a time based period register now you will say why that time base period is there because that time base counter value which is 0 to 2 to the power 16 that will be stored in your time based period register
            • 48:00 - 48:30 okay so this time base period register is for users use that is it is for our use that it is our wish if you want to put some value for any counter from 0 to 2 to the power 16 so we can put that value into time based period register and this time base period resistor will actually determine the frequency or time period of your pwm signal now how that will happen that i will tell you in a minute before that you need to remember that you also have a shadow resistor over here in order to
            • 48:30 - 49:00 understand the concept of shadow resistor i'll tell you an example let's say it is not useful to you in any any aspect but you should you should know okay why it is there so it is there let's say your time base period register is updating continuously so if uh it does not have a backup where it can store its previous value before taking the actual value then it will be it will be causing little bit mismatch into that value and you will not have clear understanding you'll not get
            • 49:00 - 49:30 accurate value of what is that what is the value of that time based period resistor okay so what exactly happens is you have a shadow resistor which actually previously stores the value of period register before getting loaded into it so that it has its own backup so whatever actual value you are putting with certain delay due to microcontroller peripherals working and all this shadow resistor its have its own memory and it is related to your main processor that can be that transferred into your period register so the shadow register
            • 49:30 - 50:00 you can take an example like if your cpu is there and it is executing all the instruction and let's say certain other interrupt is being called by you and if your microcontroller is jumping onto that address then your previous address your microcontroller needs to remember right key to which address he needs to go back in order to continue its execution before going into that particular interrupt so what he does is it stores its uh that particular destination from
            • 50:00 - 50:30 here he was jumping to interrupt into a resistor called as program counter generally so that program counter remembers the location of microprocessor so whenever the interrupt task is complete that a microprocessor will go to that program counter and it will start executing its instruction one by one once again so that program counter it's like a shadow resistor so let's say if you have put some value into period resistor and then your microcontroller is coming to that period register in order to ask him the
            • 50:30 - 51:00 value so let's say period resistor has that value previously and now shadow why shadow is coming into the picture because it will be there will be certain delay with respect to your microcontroller main execution of period resistor instruction and your main instruction so that shadow will give you that backup delay so that shadow register will store the value of that period resistor particularly okay so it's the use of that shadow resistor then uh this was about time based submarine okay now how do we decide
            • 51:00 - 51:30 frequency of this pwm and all and how do we actually generate the pwms okay that i will explain now so till here does anybody has any doubt does anybody has any doubt okay
            • 51:30 - 52:00 okay soom is not there with us right so thank you so i will send one wideboard whiteboard request if it is possible for you
            • 52:00 - 52:30 okay you can accept it and see whether i can write some to something into this board or not it will be little bit easy for me
            • 52:30 - 53:00 okay it will be little bit hard to write with this i guess okay anyways so you understood till this point what i wanted to say i think it's clear to everybody so what i want to say is is my screen visible to everybody yes okay so from here
            • 53:00 - 53:30 we saw that our epwm clock okay it was at system clock divided by two it means our epwm clock was working on redmi note is it clear to everybody oh yes we have a time-based clock this time based clock is actually
            • 53:30 - 54:00 divided by your epwm clock through clock pre-scale right this clock pre-scale till here we saw right so this clock pre-scale it is having two resistors as i told before one is clock division and another one is hsp top division okay so
            • 54:00 - 54:30 we will reduce its size so that it comes in the one fighting is fine now okay so uh we saw that our epw clock if it is working on 100 megahertz our time based clock will working on we'll be working on epwm clock divided by clock free scale that is clock division and hsp clock division so that can be equal to
            • 54:30 - 55:00 your main clock of 100 megahertz it will be divided by for clock division into hsp log division now i can set any value over here into this clock division and hsp clock division in order to have my time base clock right so let's say if i'm setting this value as 1 and this value is 2 so i'm putting here clock division as 1 and hsp clock
            • 55:00 - 55:30 division at 2 so what will be my frequency it will be i guess 50 megahertz right so 50 megahertz it means the time for my tv clock it will be 20 nanoseconds right what time i am talking about is is it clear to everybody like we saw in the presentation this time for time based clock the time which i am talking about
            • 55:30 - 56:00 is actually this time okay is it clear to everybody this is the peak lock timing so i'm saying if my clock is operating because this is what my time based sub module is doing right my time based sub model has a time based counter which is running from zero to certain value and that's why the clock frequency of that time base counter okay and the
            • 56:00 - 56:30 timing for that counter will be t clock am i correct so i am saying that time for particular counter to rise from one step to another step will be one divided by the frequency of that particular time base counter to which i am operating right so is it clear to you all okay so the time for time base clock is 20 nanosecond okay what i am doing here
            • 56:30 - 57:00 is i am going to tell you how do you obtain the formula for generating epwm pulses frequency so it is very necessary for you to understand what i am exactly saying over here because very we are very near to understand the formula of that epw okay now before going into that okay so this was till here everything is clear to everybody i guess now
            • 57:00 - 57:30 as i talked about there are two register into time based sub module one is time base period register another one is time based counter register so what my time base counter register is doing pvctr what it is doing is is raising its value from 0 to 2 to the power 16 because it is a 16 bit counter and this is a counter which is performing the operation okay but where i need to put all this value
            • 57:30 - 58:00 into a register called as tbprd so pbprd will have value from 0 to 2 to the power 16. so this is the operation that your counter is performing okay this is the operation that your counter is performing and it is counting from 0 to 2 to the power 16 okay and what is the timing for each step that is 20 nanoseconds okay the time for each step for counter to rise from 0 to 2 to the power 16 is
            • 58:00 - 58:30 equal to 20 nanoseconds now in this slide if you see there are three types of counter shown over here one is up count another one is down count and third one is up down countable so in up count mode you can see my time base counter is starting from 0 and it is counting up to tb brd so tb prd is a time based period register which is having certain value which is limited up to 0 to 2 to the power 60 and
            • 58:30 - 59:00 time base counter is a counter into that time based module which is performing this operation of counting and what is the time for counting each and every step is tb clock equal to 20 nanoseconds okay now this is about counting now you can see here similarly your countdown mode like let's say if you are operating your counter in countdown mode your tbprd will start counting from tbprd to zero then again it will start then again it will reset to zero then
            • 59:00 - 59:30 again it will start then again it will reset to zero so it is a down count where you are counting from seven to zero as we saw in down counter now we have up down counter in which you will be counting from zero to tb prd and then from again tb prd to back to zero so this will be responsible for creating your symmetrical waveforms now you can see yellow dots over here what these yellow dots mean is your compare values are particularly touching onto those waveforms onto those particular points
            • 59:30 - 60:00 so we have another sub module here which is coming into the picture which is called as a counter compare sub model so what this counter compare sub module does is it consists of four resistor compare a compare b compare c and compare d resistor so compare c and compare day resistor are used for event trigger application like let's say you want to trigger a certain certain event a certain period of time so you can use this compare c and compare d resistor why what i mean by event is i mean interrupt only like
            • 60:00 - 60:30 we saw in interrupt if i'm creating any interrupt i go on performing another task so let's say i want to create certain event at certain particular instant where let's say i'm rising on this value and i want to create an event where comparator is touching up value so i can create the event with the help of the comparative c and comparator these so these are the non-accessible resistors to you okay you cannot put any value into this resistors but only compare a and compare b are there which are available to you in order to program so that you can
            • 60:30 - 61:00 generate the pwm pulses now how can you generate the pwm pulses suppose this tb prd value is 2000 and i'm putting thousand into this comparator a and thousand into this comparator b now what will happen is this comparator a will be there in middle similarly comparator b will be there in middle and your time base period will be at two thousand now there are actually four events from this picture if you see one is at zero another when time based counter is
            • 61:00 - 61:30 touching comparator a another one is when time base counter is touching comparator b another one is when your time base period is having okay sorry your time based counter is having value which is equal to tb prd so how many events are there into this particular one four events are there what are the four events first event is your tb counter can be equal to 0 another event is another event is
            • 61:30 - 62:00 another event is if your time base counter is equal to your compare a value third event is if your time base counter is equal to your comparator b value and final event is tb counter is equal to your pb prd value why i am saying like this
            • 62:00 - 62:30 because this counter is incrementing if you observe this comparator to be constant if you observe this comparator to be constant but your counter is counting from 0 to tb pld and then again it is getting reset so you have four set of events which you can trigger to which you can generate the pulses like i can generate the pulse at zero i can ask pulse to get reset at tb rd i can ask pulse to rise at comparator a i can ask pulse to rise at comparator v whatever is my wish according to my wish
            • 62:30 - 63:00 i can program this particular pulse at what value i want to generate now let's see if tbprd is here and comparator a or comparator b is in between somewhere here and if i say that i have to trigger my pulse when this comparator a or comparator b is touching the middle way then my duty will be 50 so if this comparator a and comparator b will be having half the values of tb pld then your duty will be 5 if it is having 10 percent of this tbp id then your duty will be 10
            • 63:00 - 63:30 so depend on your comparator and action qualifier action qualifier is what another resistor that i am using to set and reset the pulses see every time whenever you are setting certain values into this you need another some sub module which will tell you that when you have to set and reset the value so in that case what comes to the picture is action qualifier action qualifier is responsible for taking any action for generation of your pwm pulses so whenever let's say you have certain
            • 63:30 - 64:00 events over here and you want to generate the pulses and i'm saying at comparator a i want to on the pulse and when comparator a touches the down side of the pulse i want to switch off the pulse so that is in my hand whenever i want to on the pulse and off the pulse at particular period of instant particular comparatory uh you know touching comparator event touching tpprd event touching zero event it depends on me i can even set it at tbp or debit and then i can reset it at zero event so how
            • 64:00 - 64:30 in that case how my pulse will be it will come from here it will rise at tb prt then it will stay on for that period of time and if i am resetting at zero it will go again zero again same time it will be 0 till here and if i am setting it at 2 riser tbprd it will rise over here then again it will be constant and at 0 it will be again 0. now imagine that this is so flexible that i can try to create my pulse at any period of time but what will be the exact
            • 64:30 - 65:00 frequency of my pulse that will depend on the time duration of this particular counter like my counter if it is rising from 0 to tbprd and from tb prt to 0 it means i am tracing this tbprd value twice right so from here if you see this pulse which is rising at comparator a and this pulse which is rising at which is again rising at comparator a so you can see from here that this particular pulse whenever you ask
            • 65:00 - 65:30 him to rise and fall okay there will be no issue you can right ask to rise in over this event you can ask to follow him over this event any event but your your duty may vary whatever you want to put in comparator your duty will vary according to that but your pwm frequency to which your signal is generating that will be constant because your tv prt is constant and every event is repeating after certain period of time so that's why the frequency of this pwm
            • 65:30 - 66:00 pulse will depend on what tb prd value you are putting out over here let's say i will explain this let's say let's say this is a three bit counter okay now what i have is i have certain time here t clock okay and this time period is around five nanoseconds or ten nanoseconds and how
            • 66:00 - 66:30 much value it is taking in that 5 nanosecond is 2 q that is 8 okay so what will be the total time period of this it will be equal to t clock into 8 nanoseconds am i correct you are rising step by step with certain period of time so what will be your value your value will be t clock into 8 nanosecond if this is 16 it will be t clock into 16 nanosecond if that is 18 then your value will be t clock into 18 nanosecond
            • 66:30 - 67:00 okay so in this case this is what the total time for any particular pwm so this total gives you time for pulse width modulation like let's say you are setting your pulse over here and you are clearing it over here then what will happen is you will have a duty but you will have a frequency which is equal to this total tbprd so the frequency of your pulse okay frequency of your pulse
            • 67:00 - 67:30 it depends on your total time okay and that time let's say you are giving it as tpwm it will be equal to 2 into what is the time for each clock to rise into your tb prd and how will you obtain the frequency of
            • 67:30 - 68:00 your pwm frequency of pwm will be equal to 1 by ppw so oh i am writing this too this two is there because i'm using up down counter mode let's say i'm using only up count more in that case it will be one because in up down count mode that tv prd will be traced twice with this particular type so if you have two here and tv clock of 20 nanosecond and you are having tv prd of 2000 then your total time period will
            • 68:00 - 68:30 be 2 into 20 nanosecond into your 2000 and that total will be divided 1 divided by that total product will give you your frequency of pw understood clear to everybody till this point does anybody has any doubt okay so if anybody did not understand
            • 68:30 - 69:00 anything they can ask me okay so this was there and this is how you write particular frequency of your pwm okay we'll verify this through our code as well now what is the frequency of our pw so now you can see from here from this slide that your pwm frequency it depends on time for time based law and your time for time is clock it depends on your clock dividers and this clock dividers are in your hand like you can set the value of this clock division and hsp clock division and according to that
            • 69:00 - 69:30 your time for time base clock will be there right so this is a frequency of tb clock then you will have your time as 1 by tb clock okay so this time for tb clock is actually came from 1 by eb clock so tb clock is nothing but frequency and this tv clock is a time for time based clock okay so this is 1 by 50 megahertz which will be equal to 20 nano second this time this counter will be start counting from 0 to 2 to
            • 69:30 - 70:00 the power 60 so you well understood there are actually three four registers that you need to remember one is your tb prd then your comparators and then your action qualifiers so action qualifiers will give you action when to set and when to reset any particular pwm pulse that will be clear when we will see our code okay so basically what is happening is we are generating epwma and epwm b through this four particular things okay
            • 70:00 - 70:30 so you don't need to remember this this i have told you every already what is the formula for pwm i've told it in a more simpler way so that you guys will understand from this side yes it is clear to you how to set frequency for your main pwm is it clear to you okay okay
            • 70:30 - 71:00 is my screen visible to everybody now but are you saying something
            • 71:00 - 71:30 just hold on for two minutes i have to open another version of cc's in order to demonstrate you the code we'll see how it exactly happens
            • 71:30 - 72:00 so that it will be easy for you to understand so this was about the theory of epw okay there are many things to happen into this one it's not like it's over there are many some modules that we have to look into and how they are going to help you while designing your algorithm from a particular file like how pwm chopper is used how deadband is used how trip zone is used that we will see this digital compare sub module is there in order to expand the capabilities of your trip zone sub model okay like if you want to
            • 72:00 - 72:30 generate certain trip zone events when you want to compare two digital signals they can then it can generate your interrupt to pi block as well okay so this digital compare is there in order to expand the capabilities of your trips then you have input crossbar that signals coming from uh one particular pin to another particular pin uh then you have epwm crossbar that is signals routing from pwms to pwms or pwms to input our input crossover so that will see how exactly the exercise for that will help you to understand
            • 72:30 - 73:00 since every sub module has its detailed explanation i'll take everything one by one so that you will not get confused then you have a peripheral then you have event trigger resistor which which can trigger any events such as soc event or trip zone event to pi module or adc module we'll see adc and dac as well so don't worry about it and uh there are certain things that you need to understand uh so i'm showing you a little bit
            • 73:00 - 73:30 of code so that you get familiar with the resistors what frequency pulse it is generating and all we'll see that on oscilloscope as well okay once it is available if probably in the afternoon session today if it is available we will see the output of any pulse
            • 73:30 - 74:00 whether we are setting the frequency formula is correct or not to verify that particular thing will see into the oscilloscope we'll take more exercises like uh one one exercise will take where we'll uh route the signal from the board into the board itself through adc and when we'll change the potentiometer we see that the level of that signal will be changing by adding the resistance into it so that exercise also we are going to see
            • 74:00 - 74:30 one more thing i would like to tell you is if somebody is looking into i think someone was interested into variable frequency pwms so from here if you see that if your comparator are varying continuously your frequency can be variable okay let's say if your comparator is changing continuously from 0 to tbprd and you have set and clear the epwm pulses on particular
            • 74:30 - 75:00 event or particular time or particular values then what will happen is it will try to follow its instruction but since comparator is changing continuously you know since comparator is changing continuously what we can say that your pulse frequency will be your pulse duty will be changing frequency will be constant your pulse duty will be changing okay we'll see how to generate other things as well like in variable frequency way how we can do that
            • 75:00 - 75:30 so your duty will be changing if you vary this comparator particularly okay frequencies will be constant we'll see how to use it for variable frequency as well
            • 75:30 - 76:00 okay right
            • 76:00 - 76:30 so i'll import an example of epw i'm repeating this process so that it will be you you'll be a little familiar when i'm doing it here you can go to software and then
            • 76:30 - 77:00 here there will be list of examples so you can click on epwm up down counter and epwm up counter so
            • 77:00 - 77:30 so from here you can see that some of the registers that i was talking about is the tpprd resistor so this is a epwm one module and this is a predefined uh keyword which is initialized epwm one example okay so there are whatever pwm is given to you all the examples will be there so
            • 77:30 - 78:00 all the predefined functions like we saw yesterday that every function has its api associated with it so just like this epwm dot c is also an api which is related to epw initialization and from here we can see that all the initialized epwm one gpio two gpio three gpio all the pwms are initialized through gpios okay so this will be initialization of epwm one gpio then uh you can see here that in gpa max1 gpa 0 is set as 1 so whenever gpio 0 in
            • 78:00 - 78:30 a max 1 is set as 1 it means the gpio 0 is now acting as a pwm 1a and epw gpio01 is acting as a ppwm 1b okay so like this epwm pin two and three are initialized and in this one it is selected through gpio and peripheral maxim so i hope it is clear to you how any particular same pin is set as pwm and as well as gpio okay so
            • 78:30 - 79:00 when it was zero it was acting as a gpio pin and if it is one it is acting as a pwm pin from this epwm you can see that there is one resistor that is epwm registers dot tvprd so this tbprd is a time based period register that we saw which belongs to time based sub module and it is having value from 0 to 2 to the power 60 right now user has given it to the variable the epwm one timer time base period he must have defined this value over somewhere in the initial time
            • 79:00 - 79:30 you can see here it has he has defined 2000 value in a period register okay so he has assigned 2000 to epwm timer time base period so that value is there into t v prd you can as well give it directly here okay you can if you want to put 2000 we can as well put it here as well so there will be no issue with that this register we'll see later it's belong to time based phase shift how to add a phase shift between pwm module okay it is selected through this vbphs register and this is your time based counter so
            • 79:30 - 80:00 time based counter you have to assign it to zero whenever you want any phase shift your tbp hs value should be equal to your time base counter so that your counter will start incrementing from the phase shift which you have put so your triangle will not start from zero now it will start from the tv ph as well okay in that way you will already have a phase shift between two models so we will see how to do that as well when we have oscilloscopes so we have a comparator a over here comparator b over here so you can see
            • 80:00 - 80:30 in this comparator a resistor of comparator a he has set some minimum value of comparator maximum value of comparator b so you can put anything over here so comparator a is responsible for generating epwm 1 a pwm 1 a and comparator b is responsible for generating epwm 1b okay so if you develop one b signal will be generated if you are having sorry i make a mistake but like this
            • 80:30 - 81:00 let me see how we can see actually you have flexibility in action qualifier as well so this was about comparative you can put any value into comparator a and comparator b but this value should not be more than your tbprd okay if your tb prd is 2000 it should be 2000 within if it is more than 2000 then what will happen you will not able to get any pulse because comparison will not be happening okay so it should be from 0 to your tbpid whatever value you are setting okay then you have a counter mode here so tb
            • 81:00 - 81:30 control register this is tb ctl which is a tv control resistor and it is used in order to set your counter mode so one bit into this time based counter time based control resistor is a counter mode bit counter mode bit is there in order to set any particular mode for turning on and off the pulse if you set here up down it means your up down counter mode will be on if you set here up your account will be on if you set your down your down count will be on so you'll have only a symmetrical
            • 81:30 - 82:00 waveforms if you are using only one counter mode if you are using both the counter mode that is up down counter mode then you will have a symmetrical waveform that is triangular waveform and now you must be thinking why this tv count up down is written here why not others so you can what you can do is you can just copy this tv ctl okay and you can go to your technical reference manual and if you put search over here and if you go to tv control
            • 82:00 - 82:30 okay yeah
            • 82:30 - 83:00 so from this time this control resistor you can see these are all the bits of that particular time based register in which you can see particularly bit number zero and one belongs to counter mode so in this bit one bit zero and bit one okay belongs to counter mode if you put zero zero it will be of count more if you put one it will be down count more if you put one zero it will be up down count more so one zero in the sense if you convert this binary into decimal it will
            • 83:00 - 83:30 be two so if you put two it will be running in up down count mode if you put one it will running in down count mode if you put zero it will running in up down up count mode okay so you can see from here that this tv count up down has already a macro expansion of zero cross two so it means the value of this is 2 so it is running in up down count mode so these are the predefined variables which are there into your i guess somewhere
            • 83:30 - 84:00 in epwm defines dot h header file so in this header file you can see all the examples which actually taken all the predefined variables are shown over here so if it is a count up it will be having zero value if it is countdown it will be having one value if it is up down count it will be having two value okay so it is like that now similarly you can see this is a another bit of time based control which is phase shift enabled so we don't want
            • 84:00 - 84:30 phase shift right now so we have put it here as a disabled we can as well put it here as enable but you have to see first what enable is assigned to okay so from epwm defines dot h you have to see tb enable is set to 0 cross 1 so even if you put 1 here in this particular thing even if you put 1 over here it will be enabled and if you put 2 over here sorry if you put 0 over here it will be disabled okay so this is to disable phase shift so if you want to
            • 84:30 - 85:00 enable phase shift you can put some value over here like let's say you want to have phase shift i'll tell you that later so another thing i want to tell you is time based control register two bits that is clock division and hsp clock division so what bit of twist over here is as i told you there are two clock dividers two time base control that is epwm clock and we saw from presentation that your time based clock it is uh divided by clock division and uh hsp
            • 85:00 - 85:30 clock division sorry your epwm clock is divided by clock division and hsp clocked and i have multiplied here by one cross two okay why i did that is because if you go to
            • 85:30 - 86:00 yeah so is it visible to everybody
            • 86:00 - 86:30 there you can see from here you can see these are the two bits clock division and hsp clock division of which register time based control resistor okay it belongs to tbcp tvctl bit we are choosing so that's why we have written here tbctl.bit okay so dot hsp clock division bit we are choosing from here so if we are looking into hsp clock division we can see by default on reset this clock division is
            • 86:30 - 87:00 set to 1 okay so even if you put 0 0 0 okay it means it is by default on reset to 1 so whatever value you put in clock division if you put 0 0 0 it will be divided by 1 if you put 1 it will be divided by 2 if you put 2 it will be divided by 4 if you put 3 it will be divided by 8 y 3 because 8 4 2 1 if you convert it into decimal it will be 3 so if you divide it by 3 it will be divided by 8 after that the more you go on increasing this clock the lesser clock frequency
            • 87:00 - 87:30 you will be having with your time based clause you don't want that of course it is a disadvantage but if somebody wants to work at a lower frequency it's for them okay now you have hsp clock division so hsp clock division it is by default on reset it is set to two so even if you put 0 0 0 it will take value as clock divider by 2 okay so your time base clock will always operate on 1.2 okay so if you put 0 0 0 into hsp clock
            • 87:30 - 88:00 division it will not be divided by 1 it will be divided by 2 and when you are putting 1 it will not be divided by 2 but it will divided by 4 okay so there is a mistake in this technical reference manual over here so when you run your program you will understand what i was saying so by default on reset this clock is put to zero and by default on reset if your clock will be go to two so your time base clock now which is a formula given by pwm clock divided by hsp clock division and main clock division will be
            • 88:00 - 88:30 1 cross 2 okay so if it is set at time division and base division 1 and 1 it means their value is 0 macro expansion is 0 from here you can see its macro expansion is 0 so this is defined as 0 0 it means it will be 1 cross 2 okay so then you have a shadow mode register you don't have to change anything over here what you have to put is as it is this registers what does it mean is you are loading your comparator resistor when
            • 88:30 - 89:00 your compare counter starts from zero you can as well load your comparator resistor when you compare counter starts from tbprd so there are two events that you can start from one is from zero and another one is from tbprd so it will help you to maintain the synchronization as well okay so you don't have to do anything whenever you are triggering all the modules you have to comparator you have to load on to zero or time base period all the time okay then you have a shadow mode you just have to click here cc shadow okay you don't have to worry about this instructions much
            • 89:00 - 89:30 then you have a action qualifier so in this action qualifier you can see that action qualifier ctl a what does it mean is action qualifier control a so in this bit you are selecting comparator a up count so what does it mean whenever your comparator a touches the up slant of your counter it will set the pulse okay and when it teach it touches the down slant of your particular counter it will clear the pulse so in this way control a is used
            • 89:30 - 90:00 for generation of epwm a and control b is used for generation of epwmp so you can as well generate epwma with the help of comparator b okay like you can set it at comparator b up comparator b down and this one at comparator a up comparator b down whatever is your wish okay so you can just put set and clear as the second clear has already defined as two and clear is defined as one so obviously
            • 90:00 - 90:30 if you go to a qctl a resistor in this particular technical reference manual if you go and search you can see from here that you're selecting comparator a down bit and if you are putting 0 it means it is doing nothing if you are putting 1 it means it is setting epwm a as low then if you are setting one zero it means it is forcing epwm one to be high so in this way action qualifier will work so if you put one here your epwma
            • 90:30 - 91:00 will be high that is it will rise if you put one over here sorry two over here it will rise if you put one over here it will clear the pulse so in this way you can generate your pulse with action qualifier resistor so this will be control a will be limited to epwm 1a and control b will be related to dpwm 1b then this interrupt will talk about this later as we are as time has passed so we'll look into other things later so till here everything is clear to you
            • 91:00 - 91:30 is there any doubt so i guess now it is clear to you how are you generating pwm frequency so if your tv pid is 2000 and your tv clock is 20 nanosecond and your time is you are using up down count mode so 2 into 20 nanosecond that is 40 into 2 that will be 16 so 1 by 16 i guess whatever that comes out to be that will be your frequency