This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
hi
i am using TMS320F28335 DSC for the design of an inverter.
In the DSC i'm using the ePWM modules to generate the gate pulses for the inverter.
i've written the code and the only doubt is--- how to start the TBCTRs of the ePWM modules..??
i synchronized the TBCLKs of all the 3 epwm modules that are needed by setting the TBCLKSYNC bit in the PCLKCR0 register. i.e.,
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
I initialized the TBCTRs of all the 3 epwms with 0. And then i synchronized the TBCLKs. Is it that the TBCTRs start incrementing right the moment i synchronize the TBCLKs, or should i have to start them by modifying any register... ?? if so, what is that register???
i am new to this community..
EXCUSE ME IF I POSTED IN THE WRONG FORUM. AND LET ME KNOW THE SAME.
thanks in adv.
Hi Bob,
Welcome to the community!
A good starting point is to use the 2833x C/C++ Header Files and Peripheral examples software package to see how software for certain peripherals is written.
TBCLKSYNC is EALLOW protected, which means you must add "EALLOW;" prior to writing to this bit:
//So, prior to configuring ePWM modules:
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // Stop all the TB clocks
EDIS;
//Then configure ePWM modules here
//Then after configuration is over, enable TB clocks:
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Start all the timers synced
EDIS;
Regards,
Christine.
yes, i know that it is EALLOW protected... i included all that stuff in my code..... i wrote only that statement just to give an example...
in fact i have gone through the examples also. Even there, i didnt find any special register set/clear s for starting the TBCTRs....
just the TBCLKSYNC was set and then that's it....
i used a XDS100 kit and found that the waveforms are coming in the oscilloscope..... But, in the debug mode, when i tried to monitor the TBCTRs, i found that they were not incrementing ... and the interrupt which is supposed to generate at TBCTR=TBPRD is not getting generated....
when this is the case in simulation mode, i am still getting the waveforms in emulation...... ????
HOW COME???
any suggestions???
bob_ashley said:But, in the debug mode, when i tried to monitor the TBCTRs, i found that they were not incrementing ... and the interrupt which is supposed to generate at TBCTR=TBPRD is not getting generated....
If I understand, you are halting the processor and then checking the counters. The counters will stop incrementing unless you have configured the soft/free bits in the ePWM module to allow them to continue when you halt the processor. Also if you single step you won't take the interrupt - you will need to run.
Hope this answers your question
Cheers
-Lori
@ Lori
dear lori,
first of all, thanks for ur suggestion... after u suggested for the free/soft, bits, i initialized them for free run mode. by initializing 2.
but then also i am getting the same problem.. no increment in counter.... i made a RUN in the debug mode, not a single step. and when i HALTed in between to see my counter values in the watch window, they still are at 0, all the three TBCTRs ..
i will tell u my exact requirement... my code goes like this...
in the main function, i've just initialized all the required things, including the epwm modules(up-down mode).... then i made the TBCLKSYNC=1;
and then i run a infinite loop.. then when a interrupt gets generated at TBCTR=TBPRD, my subroutine should calculate the values of CMPB values for all the 3 epwms and then load them into the the respective shadow regs.... which will be loaded back to active regs at TBCTR=0.
so, now my counter is not incrementing(in the debug mode) and also the values of CMPB are never getting updated..... which means that the control never enters into the ISR
any suggestions?????
Bob,
I have a couple of suggestions
- Do the peripheral examples Chrissy mentioned work on your system?
- Do all of the ePWM registers read back 0? If so I suspect the the clock to each of the ePWM modules has not been enabled. PCLKCR1 is EALLOW protected.
SysCtrlRegs.PCLKCR1.bit.EPWM1ENCLK = 1; // EPWM1
SysCtrlRegs.PCLKCR1.bit.EPWM2ENCLK = 1; // EPWM2
SysCtrlRegs.PCLKCR1.bit.EPWM3ENCLK = 1; // EPWM3 etc...
Regards
-Lori
Lori,
they have been enabled. Or else, i wouldn't be getting the output in the oscilloscope.........!!!!!!!!!!!!!
so practically speaking, i am getting the output... but only in debug mode, i'm facing the problem....
And one more thing, as per your knowledge, do u know whether there is any specific way to start these TBCTRs. generally in normal microconts, that i previously used, there used to be a bit which i shud set so as to start the counter, But in this DSC, i didnt find any such register which needs to be modified. and i've gone thru the 28xx ePWM user guide also.... even there, nothing has been mentioned specifically as of when they are goin to start incrementing.
Bob,
bob_ashley said:do u know whether there is any specific way to start these TBCTRs. generally in normal microconts, that i previously used, there used to be a bit which i shud set so as to start the counter
Yes - TBCLKSYNC holds the counters until you set it to 1. This releases the counters and they will begin counting. Since the ePWM pins are toggling the counters must be counting, right?
When you halt the processor do the pins continue to toggle?
Please check if all the ePWM registers read back zero? I'm wondering if Code Composer is blocking the debug read of the registers. CCS (I'm assuming V3.3 here) uses a file called a .gel file to become aware of the device's memory map. If a memory region is not defined for CCS it will keep you from reading that memory on the physical device.
Can you check that you have a gel file loaded and the name of the gel file? It will show up in your project window (above the project itself under gel files) in CCS 3.3. If it is not there, gel files for each device are included in the header file package. You may need to disconnect and reconnect to the target or use the gel pulldown menu to setup the memory map.
If you step through the code and init TBCTR to something other than 0, do you see a different value in the register?
Regards
-Lori
ahh......... sorry Lori,
i was really so much busy doing my project that i didnt even dare to connect to the net....
at last, i got the OUTPUT.....
as i told u, i couldn't get the TBCTRs incrementing in the simulator mode.... but when i tried it today again using emulator on a kit in my lab, i found that my counter was incrementing...... now plz dont ask me why? bcoz i truely dont know the reason. and more over i was not getting the interrupt in the single step mode. As u suggested me that it is not possible to get the int in single step mode.. thn i tried out the RUN ..... and also, as u said, setting TBCLKSYNC itself starts the TBCTRs of all the modules.
i had faced one more problem.. i was gettin intrpt only for the first time.. that's it ...., i was not getting the interpt at next event..... then i tried out all the things.. and then came to know that the flag corresponding to it was set and i has to be reset before the next interrupt has to be serviced (i was thinking that flag will get automatically reset once the execution of ISR gets finished).... so any how after all experimenting on it, i got the output for open loop control ..... now i have to work on closed loop operation..
i would thank u for ur suggestions...... and also, can u just brief me abt the diff b/w simulator and emulator... and how actually is emulation different from burnig the code onto the processor... (i am a student and i didnt study any courses relating to these microcontrollers it is out of my interest that i am using them for my projects in power electronics...!!!!!!)
bob_ashley said:as i told u, i couldn't get the TBCTRs incrementing in the simulator mode.... but when i tried it today again using emulator on a kit in my lab, i found that my counter was incrementing......
Bob,
I didn't realize you were using the simulator. When you said debug mode I thought you meant using an emulator connected to silicon since the signals were toggling. Sorry for the confusion.
bob_ashley said:can u just brief me abt the diff b/w simulator and emulator... and how actually is emulation different from burnig the code onto the processor...
The simulator is a software only model running on the PC - it doesn't interract with the MCU at all and has limited funcionality. It simulates the CPU and folks may use it to start out but it is quickly outgrown during development. As you saw it doesn't have all of the peripheral hooks. Low-cost tools are a better way to get started.
An emulator is a connection to the JTAG port of the device that lets you see what is going on in the device. You can see the registers, memory, step etc. Everything that goes on is done by the device itself and the results reported back to Code Composer Studio for you to view. Using an emulator you can load and run your code in RAM or Flash.
If you want a stand alone device that will go out into the field you will most likely program the code into flash. Some time critical code may be copied into RAM and executed there.
Regards
-Lori
Lori,
as u were saying that the emulator will run the code on RAM or FLASH, then why cant it be directly used as a stand alone device once it is emulated( as the stand alone device also needs the code to be burnt/loaded onto the FLASH....?????
can u provide some more materials (pdfs/docs) which will give more insight into these JTAGs and related stuff
any how thanks for the help provided
bob_ashley said:as u were saying that the emulator will run the code on RAM or FLASH, then why cant it be directly used as a stand alone device once it is emulated( as the stand alone device also needs the code to be burnt/loaded onto the FLASH....?????
Yes, if you program the flash using CCS and an emulator then the device can be used stand alone. If, however, you only use RAM while developing your application with CCS via an emulator then the device will not be ready for stand alone use.
-Lori