Tool/software: TI C/C++ Compiler
Hi Expert,
In order to accelerate code execution time, could we use HWREGH() instead of bit field function to replace driverlib code?
Thanks!
Rayna
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.
Tool/software: TI C/C++ Compiler
Hi Expert,
In order to accelerate code execution time, could we use HWREGH() instead of bit field function to replace driverlib code?
Thanks!
Rayna
Hi Rayna,
There are multiple ways of accessing peripheral registers - direct register access, driver library (DriverLib), and bitfields.
The following diagram indicates the comparison between the different ways. HWREG can be used to increase the code efficiency by accessing the registers directly, however DriverLib is the preferred model. Refer this link for more details
https://software-dl.ti.com/C2000/docs/software_guide/c2000ware/drivers.html
Best Regards
Siddharth
Hi Siddharth,
I have tested the execution time of below code by CCS clk, and have some confusion.
EPWM_enableValleyCapture(EPWM1_BASE); // 68 * sysclk
ASSERT(EPWM_isBaseValid(EPWM3_BASE)); //54 * sysclk
EALLOW;
HWREGH(EPWM3_BASE + EPWM_O_VCAPCTL) |= EPWM_VCAPCTL_VCAPE; // 12 * sysclk
EDIS;
Why "ASSERT(EPWM_isBaseValid(EPWM3_BASE));" need so much time to execute, and could this line be deleted if time limited?
Thanks!
Rayna
Rayna,
The assert macro is required by the ANSI standard for C. It tests the given expression, and if it is zero, a message is output and the program exits.
The TI implementation of assert calls the standard C I/O functions fputs and fflush to output the message. These functions, in turn, call many other functions in the compiler RTS library. Hence it takes more time.
Also ,assertions should never stay in production code. It should be changed to a run time error check, i.e. something coded like this: if( condition != expected ) throw exception. So you can replace that with an expression.
Best Regards
Siddharth